How to disable a creature spawner?

Discussion in 'Plugin Development' started by Lodran, Mar 5, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Lodran

    I'm working on adding redstone control of spawners to my creaturebox plugin, and I'm having trouble figuring out a good method for disabling the spawner.

    One idea I had was to use to set the spawner's delay to a high value, but this would require me to repeatedly bump the delay on every disabled spawner, which seems like a wasteful approach.

    Another idea is to cancel the spawn event for creatures in range of a disabled spawner, which seems like it would be fairly complicated (I'm leaning toward this, if there's no better way).

    Anyone know of a better way?
     
  2. Offline

    Edward Hand

    You could set the creature type the spawner spawns to null or something like that.
    You'd only need to do that once for each spawner and it will remember it.
     
  3. Offline

    Lodran

    I thought about that, but not knowing how minecraft would respond to a null value there, it seemed a bit dangerous. Although, as it turns out setting it to spawn slimes seems to be a fine way to disable it [​IMG]. I ended up canceling the spawn events, which works pretty well.
     
  4. Offline

    Edward Hand

    I checked how it would handle it before I posted [​IMG]
    Having just double checked it seems that while the server will handle it just fine, bukkit may throw a hissy-fit for no real reason (as is often the case).

    A safer bet would be to just throw bukkit out the window and do this:
    Code:
    CraftWorld cWorld = (CraftWorld)block.getWorld();
    TileEntityMobSpawner spawner = (TileEntityMobSpawner)cWorld.getTileEntityAt(block.getX(), block.getY(), block.getZ());
    spawner.h = "herp derp";
    which will make the spawner sit there inactive.
     
Thread Status:
Not open for further replies.

Share This Page