use of cn.nukkit.event.block.BlockBurnEvent in project Nukkit by Nukkit.
the class BlockFire method tryToCatchBlockOnFire.
private void tryToCatchBlockOnFire(Block block, int bound, int damage) {
int burnAbility = block.getBurnAbility();
Random random = ThreadLocalRandom.current();
if (random.nextInt(bound) < burnAbility) {
if (random.nextInt(damage + 10) < 5) {
int meta = damage + random.nextInt(5) / 4;
if (meta > 15) {
meta = 15;
}
BlockIgniteEvent e = new BlockIgniteEvent(block, this, null, BlockIgniteEvent.BlockIgniteCause.SPREAD);
this.level.getServer().getPluginManager().callEvent(e);
if (!e.isCancelled()) {
this.getLevel().setBlock(block, new BlockFire(meta), true);
this.getLevel().scheduleUpdate(block, this.tickRate());
}
} else {
BlockBurnEvent ev = new BlockBurnEvent(block);
this.getLevel().getServer().getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
this.getLevel().setBlock(block, new BlockAir(), true);
}
}
if (block instanceof BlockTNT) {
((BlockTNT) block).prime();
}
}
}
Aggregations