本文整理汇总了Java中cn.nukkit.event.block.BlockBurnEvent类的典型用法代码示例。如果您正苦于以下问题:Java BlockBurnEvent类的具体用法?Java BlockBurnEvent怎么用?Java BlockBurnEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockBurnEvent类属于cn.nukkit.event.block包,在下文中一共展示了BlockBurnEvent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockBurn
import cn.nukkit.event.block.BlockBurnEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent event) {
Block b = event.getBlock();
Location location = NukkitUtil.getLocation(b.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = location.getOwnedPlot();
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) {
event.setCancelled(true);
return;
}
}
示例2: tryToCatchBlockOnFire
import cn.nukkit.event.block.BlockBurnEvent; //导入依赖的package包/类
private void tryToCatchBlockOnFire(Block block, int bound, int damage) {
int burnAbility = block.getBurnAbility();
Random random = this.getLevel().rand;
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();
}
}
}
示例3: tryToCatchBlockOnFire
import cn.nukkit.event.block.BlockBurnEvent; //导入依赖的package包/类
private void tryToCatchBlockOnFire(Block block, int bound, int damage) {
int burnAbility = block.getBurnAbility();
Random random = this.getLevel().rand;
if (random.nextInt(bound) < burnAbility) {
if (random.nextInt(damage + 10) < 5) {
int meta = damage + random.nextInt(5) / 4;
if (meta > 15) {
meta = 15;
}
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();
}
}
}