Search in sources :

Example 1 with FurnaceBurnEvent

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);
    }
}
Also used : BlockAir(cn.nukkit.block.BlockAir) FurnaceBurnEvent(cn.nukkit.event.inventory.FurnaceBurnEvent) BlockFurnaceBurning(cn.nukkit.block.BlockFurnaceBurning) ItemBlock(cn.nukkit.item.ItemBlock)

Aggregations

BlockAir (cn.nukkit.block.BlockAir)1 BlockFurnaceBurning (cn.nukkit.block.BlockFurnaceBurning)1 FurnaceBurnEvent (cn.nukkit.event.inventory.FurnaceBurnEvent)1 ItemBlock (cn.nukkit.item.ItemBlock)1