use of cn.nukkit.event.inventory.FurnaceBurnEvent in project Nukkit by Nukkit.
the class BlockEntityFurnace method checkFuel.
protected void checkFuel(Item fuel) {
FurnaceBurnEvent ev = new FurnaceBurnEvent(this, fuel, fuel.getFuelTime() == null ? 0 : fuel.getFuelTime());
if (ev.isCancelled()) {
return;
}
maxTime = ev.getBurnTime();
burnTime = ev.getBurnTime();
burnDuration = 0;
if (this.getBlock().getId() == Item.FURNACE) {
this.getLevel().setBlock(this, new BlockFurnaceBurning(this.getBlock().getDamage()), true);
}
if (burnTime > 0 && ev.isBurning()) {
fuel.setCount(fuel.getCount() - 1);
if (fuel.getCount() == 0) {
if (fuel.getId() == Item.BUCKET && fuel.getDamage() == 10) {
fuel.setDamage(0);
fuel.setCount(1);
} else {
fuel = new ItemBlock(new BlockAir(), 0, 0);
}
}
this.inventory.setFuel(fuel);
}
}
Aggregations