[SPIGOT-7877] Unable to add spawn potentials to trial spawner Created: 22/Aug/24 Updated: 25/Dec/24 Resolved: 31/Aug/24 |
|
| Status: | Resolved |
| Project: | Spigot |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Zedadias Wick | Assignee: | Unassigned |
| Resolution: | Invalid | Votes: | 0 |
| Labels: | 1.21, Trial_Spawner | ||
| Attachments: |
|
| Version: | This server is running CraftBukkit version 4295-Spigot-ca58122-7548afc (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT) |
| Guidelines Read: | Yes |
| Description |
|
Placing a trial_spawner and adding a potential spawn should result in a trial spawner with a potential spawn set, but unfortunately it doesn't show in the block's data and the trial spawner does not function. Using the following vanilla command would result in a trial_spawner which spawns a few waves of the specified zombie mob:
/setblock ~ ~ ~ minecraft:trial_spawner{normal_config:{spawn_potentials:[{data:{entity:{id:"minecraft:zombie"}},weight:1}]}}
But the Spigot equivalent does not:
BlockState state = block.getState(); TrialSpawner trialSpawner = (TrialSpawner) state; TrialSpawnerConfiguration normalConfiguration = trialSpawner.getNormalConfiguration(); Bukkit.getLogger().log(Level.INFO, "Blank TrialSpawner potential spawns 0: {0}", normalConfiguration.getPotentialSpawns().toString()); // Spawn entity, snapshot and remove Entity spawnEntity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE); EntitySnapshot entitySnapshot = spawnEntity.createSnapshot(); spawnEntity.remove(); SpawnRule spawnRule = new SpawnRule(7,15,0,0); normalConfiguration.addPotentialSpawn(entitySnapshot, 1, spawnRule); Which results in the following block data:
{x: 169, y: 70, spawn_data: {entity: {}}, z: 9, id: "minecraft:trial_spawner"}
I have attached a plugin for testing. It provides the command /trialspawner which will place a trial_spawner at the player's feet, and run the above code to add potential spawns. Running the /trialspawner command will yield the following in the console: [12:35:42] [Server thread/INFO]: Zedwick issued server command: /trialspawner [12:35:42] [Server thread/INFO]: Blank TrialSpawner potential spawns 0: [] [12:35:42] [Server thread/INFO]: Populated TrialSpawner potential spawns 0: [org.bukkit.block.spawner.SpawnerEntry@b1fa2fe] Which shows that prior to adding potential spawns ("Blank TrialSpawner...") it had no spawns, then after adding spawn potentials ("Populated TrialSpawner...") the normal configuration did indeed have some data. And here is the result of the `data get block` command used to view the block data of the trial_spawner placed via the command:
[12:36:03] [Server thread/INFO]: Zedwick issued server command: /data get block 169 70 9
>data get block 169 70 9
[12:50:02] [Server thread/INFO]: 169, 70, 9 has the following block data: {x: 169, y: 70, spawn_data: {entity: {}}, z: 9, id: "minecraft:trial_spawner"}
When checking the block with the `data get block 169 70 9` command it had no spawn potentials set and no 'normal_config' at all.
|
| Comments |
| Comment by Zedadias Wick [ 31/Aug/24 ] |
|
Good catch! Thank you, that was exactly the problem. Adding spawn potentials does as expected. This issue can be closed. Sorry, my mistake! |
| Comment by coll1234567 [ 27/Aug/24 ] |
|
A quick look at the test plugin shows you never update the BlockState using BlockState#update. Does the issue still occur if you call this method after adding the potential spawn? |