Solved Block burns event?

Discussion in 'Plugin Development' started by WonderWaffleYT, Mar 11, 2016.

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

    WonderWaffleYT

    Hello,
    I would like to know how to stop a block from breaking from fire while still allowing the fire to come and go on the block. So if a player lights a piece of wood on fire the wood will be on fire for a few seconds and it will not break when the fire goes away.

    The BlockBurnEvent and the BlockBreakEvent both do not work form what I have tried

    Any ideas on how to handle this are appreciated

    EDIT: This seems to be the easiest way to handle this. this works and isn't laggy :D
    Code:
    public class BlockFireEvent implements Listener{
        @EventHandler
        public void onBlockFire(BlockBurnEvent event){
            event.setCancelled(true);
        }
       
        @EventHandler
        public void onFirePlace(BlockPlaceEvent event){
            if(event.getBlock().getType() == Material.FIRE && event.getPlayer().getGameMode() == GameMode.SURVIVAL)
                killFire(event.getBlock());
        }
       
        public void killFire(final Block b){
            new BukkitRunnable(){
                public void run(){
                    b.setType(Material.AIR);
                }
            }.runTaskLater(Main.plugin, 100);
        }
    }
     
    Last edited: Mar 30, 2016
  2. Offline

    Zombie_Striker

  3. Offline

    WonderWaffleYT

  4. Offline

    ericejs123

    You need to cancel the BlockBurnEvent and I believe the fire should extinguish itself after a few seconds by itself.
     
  5. Offline

    WonderWaffleYT

    That was the first thing I tried. The fire never extinguished
     
Thread Status:
Not open for further replies.

Share This Page