Search in sources :

Example 1 with BlockBurnEvent

use of org.bukkit.event.block.BlockBurnEvent in project Glowstone by GlowstoneMC.

the class BlockFire method burnBlock.

private void burnBlock(GlowBlock block, int burnResistance, int fireAge) {
    if (random.nextInt(burnResistance) < block.getMaterialValues().getFireResistance()) {
        BlockBurnEvent burnEvent = new BlockBurnEvent(block);
        EventFactory.callEvent(burnEvent);
        if (!burnEvent.isCancelled()) {
            if (block.getType() == Material.TNT) {
                BlockTNT.igniteBlock(block, false);
            } else {
                GlowBlockState state = block.getState();
                if (random.nextInt(10 + fireAge) < 5 && !GlowBiomeClimate.isRainy(block)) {
                    int increasedAge = increaseFireAge(fireAge);
                    state.setType(Material.FIRE);
                    state.setRawData((byte) (increasedAge > MAX_FIRE_AGE ? MAX_FIRE_AGE : increasedAge));
                } else {
                    state.setType(Material.AIR);
                    state.setRawData((byte) 0);
                }
                state.update(true);
            }
        }
    }
}
Also used : BlockBurnEvent(org.bukkit.event.block.BlockBurnEvent) GlowBlockState(net.glowstone.block.GlowBlockState)

Aggregations

GlowBlockState (net.glowstone.block.GlowBlockState)1 BlockBurnEvent (org.bukkit.event.block.BlockBurnEvent)1