Solved Change Spawner Type on Block Place

Discussion in 'Plugin Development' started by JRArocks, Oct 5, 2012.

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


    I've searched the forums (probably not hard enough) and can't seem how to change the creature/entity spawned in a mob spawner in the BlockPlaceEvent. I know that the spawner will not change its type in this event, and I would like to know how to 'wait' a tick to reset it.

    Here is my current code in an event listener, which [should] set the spawner to spawn primed TNT, making an excellent land mine:
        public void onBlockPlace(BlockPlaceEvent event){
            Player player = event.getPlayer();
            if (event.getBlock().getType() == Material.MOB_SPAWNER){
                    Block bl = event.getBlock();
                    CreatureSpawner s = (CreatureSpawner) bl.getState();
                    player.sendMessage(ChatColor.GOLD+"Primed TNT Spawner placed!");
    But I need to know how to wait a tick and set it then.
    All help would be appreciated.
  2. Offline


  3. Offline


  4. Offline


    Thanks, guys, especially Muddr, I wasn't so familiar with scheduled tasks.

    But another thing: I am not sure how to get the event's block and player through a delayed event.

    EDIT: Using a repeated task (used for other things) to also control spawners.
Thread Status:
Not open for further replies.

Share This Page