Spawner NBT Tag - SpawnCount

Discussion in 'Spigot Plugin Development' started by JaKe_Talbot, Jun 1, 2018.

  1. I am currently trying the change the number of mobs that can spawner from a mob spawner.

    The only way I knew how to do it was to edit the NBT tag of the spawner the change the SpawnCount but that doesn't seem to be working. When I set the SpawnCount to any number it will only spawn 1 mob each time.

    The current code I am using:
    Code (Java):
        public void on(BlockPlaceEvent event) {
            if(event.getBlock().getType() == Material.MOB_SPAWNER) {
                CraftCreatureSpawner spawner = (CraftCreatureSpawner) event.getBlock().getState();
                NBTTagCompound tag = new NBTTagCompound();
                tag.setInt("MinSpawnDelay", 5);
                tag.setInt("SpawnCount",  10);

    I have set the MinSpawnDelay as the MinecraftWiki said that that is required for the SpawnCount to work.

    I have tried setting a different NBT tag on the spawner called "RequiredPlayerRange" to check that the way I was doing it was correct and that worked perfectly fine.

    Any help is appreciated!

    Edit: I am using spigot 1.8.8
    #1 JaKe_Talbot, Jun 1, 2018
    Last edited: Jun 1, 2018
  2. As far as I know the spawn count only affects the next "wave" of mobs and will then be set to a new random number by minecraft.

    You could try to listen to the SpawnerSpawnEvent and reset the count after each spawn to ten.

    I only remember this from messing a bit with spawners about one and a half years ago, and the wiki does tell nothing about it.
    So it could be one of the cases were the wiki is unspecific or it could be that I remember this wrong.

    Anyway I think its worth a try^^
  3. Another thing I just recognized:
    Why are you using NMS and not Spigots Block State API?
    You could simply cast the state to CratureSpawner and then use methods like setSpawnCount() or setMinSpawnDelay().
  4. I should have said in the post that I'm using spigot 1.8.8. Setting the SpawnCount is not an option available, only setting the delay of the spawner
  5. Tried this and it still only spawns one mob at a time :(