Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7877

Unable to add spawn potentials to trial spawner

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version 4295-Spigot-ca58122-7548afc (MC: 1.21.1) (Implementing API version 1.21.1-R0.1-SNAPSHOT)
    • Yes

      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.

       

            Unassigned Unassigned
            zedwick@gmail.com Zedadias Wick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: