cn.nukkit.event.inventory.FurnaceBurnEvent Java Examples

The following examples show how to use cn.nukkit.event.inventory.FurnaceBurnEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockEntityFurnace.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
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);
        }
    }