Java 类org.bukkit.event.inventory.FurnaceBurnEvent 实例源码

项目:Skript    文件:ExprFurnaceSlot.java   
@Override
protected Slot[] get(final Event e, final Block[] source) {
    return get(source, new Getter<Slot, Block>() {
        @SuppressWarnings("null")
        @Override
        @Nullable
        public Slot get(final Block b) {
            if (b.getType() != Material.FURNACE && b.getType() != Material.BURNING_FURNACE)
                return null;
            if (getTime() >= 0 && (e instanceof FurnaceSmeltEvent && b.equals(((FurnaceSmeltEvent) e).getBlock()) || e instanceof FurnaceBurnEvent && b.equals(((FurnaceBurnEvent) e).getBlock())) && !Delay.isDelayed(e)) {
                return new FurnaceEventSlot(e, ((Furnace) b.getState()).getInventory());
            } else {
                return new InventorySlot(((Furnace) b.getState()).getInventory(), slot);
            }
        }
    });
}
项目:Pokkit    文件:InventoryEvents.java   
@EventHandler(ignoreCancelled = false)
public void onFurnaceBurn(cn.nukkit.event.inventory.FurnaceBurnEvent event) {
    if (canIgnore(FurnaceBurnEvent.getHandlerList())) {
        return;
    }

    Block furnace = PokkitBlock.toBukkit(event.getBlock());
    ItemStack fuel = PokkitItemStack.toBukkitCopy(event.getFuel());
    FurnaceBurnEvent bukkitEvent = new FurnaceBurnEvent(furnace, fuel, event.getBurnTime());
    bukkitEvent.setBurning(event.isBurning());

    callCancellable(event, bukkitEvent);

    event.setBurning(bukkitEvent.isBurning());
    event.setBurnTime((short) bukkitEvent.getBurnTime());
    PokkitItemStack.overwriteNukkit(bukkitEvent.getFuel(), event.getFuel());
}
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
    Block furnaceBlock = event.getBlock();
    BlockState furnaceState = furnaceBlock.getState();
    ItemStack smelting = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getSmelting() : null;

    if (!ItemUtils.isSmeltable(smelting)) {
        return;
    }

    Player player = getPlayerFromFurnace(furnaceBlock);

    if (!UserManager.hasPlayerDataKey(player) || !Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FUEL_EFFICIENCY)) {
        return;
    }

    event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime()));
}
项目:Slimefun4-Chinese-Version    文件:FurnaceListener.java   
public void onBurn(FurnaceBurnEvent e)
{
    if(BlockStorage.check(e.getBlock()) != null && (BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace))
    {
        EnhancedFurnace furnace = (EnhancedFurnace)BlockStorage.check(e.getBlock());
        if(furnace.getFuelEfficiency() > 0)
            e.setBurnTime((int)((1.0D + 0.20000000000000001D * (double)furnace.getFuelEfficiency()) * (double)e.getBurnTime()));
    }
}
项目:QuestManager    文件:CookingGui.java   
@EventHandler
public void onItemBurn(FurnaceBurnEvent e) {
    //we don't want out stuff to burn, so cancel it if it's ours!
    if (e.getBlock().getLocation().equals(furnace.getLocation())) {
        e.setCancelled(true);
        e.setBurning(true);


        return;
    }
}
项目:Cardinal-Plus    文件:WorldFreeze.java   
@EventHandler
public void onFurnaceBurn(FurnaceBurnEvent event) {
    if (!match.getState().equals(MatchState.PLAYING)) {
        event.setCancelled(true);
        event.setBurning(true);
    }
}
项目:Slimefun4    文件:FurnaceListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBurn(FurnaceBurnEvent e) {
    if (BlockStorage.check(e.getBlock()) != null && BlockStorage.check(e.getBlock()) instanceof EnhancedFurnace) {
        EnhancedFurnace furnace = (EnhancedFurnace) BlockStorage.check(e.getBlock());
        if (furnace.getFuelEfficiency() > 0) e.setBurnTime(((int) ((1.0 + 0.2 * furnace.getFuelEfficiency()) * e.getBurnTime())));
    }
}
项目:CardinalPGM    文件:WorldFreeze.java   
@EventHandler
public void onFurnaceBurn(FurnaceBurnEvent event) {
    if (!match.isRunning()) {
        event.setCancelled(true);
        event.setBurning(true);
    }
}
项目:CraftFX    文件:RecipeListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onFurnaceBurn(FurnaceBurnEvent event) {
    // Block custom items being used as fuel in furnace (todo: add fuel power to items?)
    if (registry.get().getDefinition(event.getFuel()).isPresent()) {
        event.setCancelled(true);
    }
}
项目:SxwPlugin    文件:SxwEvents.java   
@EventHandler
public void customFuel(FurnaceBurnEvent ev){
    SpoutItemStack item = new SpoutItemStack(ev.getFuel());
    if (item.getMaterial() instanceof Burnable && ((Burnable)item.getMaterial()).getBurnTime() > 0) {
        ev.setBurning(true);
        ev.setBurnTime(((Burnable)item.getMaterial()).getBurnTime());
    }
}
项目:RoyalSurvivors    文件:SurvivorsListener.java   
@EventHandler
public void fuelFast(FurnaceBurnEvent e) {
    if (!(e.getBlock().getState() instanceof Furnace)) return;
    Furnace f = (Furnace) e.getBlock().getState();
    if (!RUtils.isInInfectedWorld(f.getLocation())) return;
    ConfManager cm = ConfManager.getConfManager("otherdata.yml");
    Location l = f.getLocation();
    String path = "furnaces." + l.getWorld().getName() + "," + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
    if (!cm.getBoolean(path, false)) return;
    f.setCookTime((short) 140); // 7 seconds in = 3 seconds left
}
项目:HCFCore    文件:FastBrewingListener.java   
@EventHandler
public void onFurnaceBurn(FurnaceBurnEvent event)
{
    Random RND = new Random();
    startUpdate((Furnace)event.getBlock().getState(), RND.nextBoolean() ? 1 : 2);
}
项目:HCFCore    文件:FastBrewingListener.java   
@EventHandler
public void onFurnaceBurn(FurnaceBurnEvent event)
{
    Random RND = new Random();
    startUpdate((Furnace)event.getBlock().getState(), RND.nextBoolean() ? 1 : 2);
}
项目:Skript    文件:ExprFurnaceSlot.java   
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
    return super.setTime(time, getExpr(), FurnaceSmeltEvent.class, FurnaceBurnEvent.class);
}
项目:CraftBukkit    文件:TileEntityFurnace.java   
public void h() {
    boolean flag = this.burnTime > 0;
    boolean flag1 = false;

    // CraftBukkit start - Use wall time instead of ticks for cooking
    int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
    this.lastTick = MinecraftServer.currentTick;

    // CraftBukkit - moved from below
    if (this.isBurning() && this.canBurn()) {
        this.cookTime += elapsedTicks;
        if (this.cookTime >= 200) {
            this.cookTime %= 200;
            this.burn();
            flag1 = true;
        }
    } else {
        this.cookTime = 0;
    }
    // CraftBukkit end

    if (this.burnTime > 0) {
        this.burnTime -= elapsedTicks; // CraftBukkit - use elapsedTicks in place of constant
    }

    if (!this.world.isStatic) {
        if (this.burnTime != 0 || this.items[1] != null && this.items[0] != null) {
            // CraftBukkit start - Handle multiple elapsed ticks
            if (this.burnTime <= 0 && this.canBurn()) { // CraftBukkit - == to <=
                CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]);

                FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.items[1]));
                this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);

                if (furnaceBurnEvent.isCancelled()) {
                    return;
                }

                this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime();
                this.burnTime += this.ticksForCurrentFuel;
                if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) {
                    // CraftBukkit end
                    flag1 = true;
                    if (this.items[1] != null) {
                        --this.items[1].count;
                        if (this.items[1].count == 0) {
                            Item item = this.items[1].getItem().t();

                            this.items[1] = item != null ? new ItemStack(item) : null;
                        }
                    }
                }
            }

            /* CraftBukkit start - Moved up
            if (this.isBurning() && this.canBurn()) {
                ++this.cookTime;
                if (this.cookTime == 200) {
                    this.cookTime = 0;
                    this.burn();
                    flag1 = true;
                }
            } else {
                this.cookTime = 0;
            }
            */
        }

        if (flag != this.burnTime > 0) {
            flag1 = true;
            BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z);
        }
    }

    if (flag1) {
        this.update();
    }
}
项目:Almura-Server    文件:TileEntityFurnace.java   
public void h() {
    boolean flag = this.burnTime > 0;
    boolean flag1 = false;

    // CraftBukkit start - Use wall time instead of ticks for cooking
    int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
    this.lastTick = MinecraftServer.currentTick;

    // CraftBukkit - moved from below
    if (this.isBurning() && this.canBurn()) {
        this.cookTime += elapsedTicks;
        if (this.cookTime >= 200) {
            this.cookTime %= 200;
            this.burn();
            flag1 = true;
        }
    } else {
        this.cookTime = 0;
    }
    // CraftBukkit end

    if (this.burnTime > 0) {
        this.burnTime -= elapsedTicks; // CraftBukkit
    }

    if (!this.world.isStatic) {
        // CraftBukkit start - Handle multiple elapsed ticks
        if (this.burnTime <= 0 && this.canBurn() && this.items[1] != null) { // CraftBukkit - == to <=
            CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]);

            FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.items[1]));
            this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);

            if (furnaceBurnEvent.isCancelled()) {
                return;
            }

            this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime();
            this.burnTime += this.ticksForCurrentFuel;
            if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) {
                // CraftBukkit end
                flag1 = true;
                if (this.items[1] != null) {
                    --this.items[1].count;
                    if (this.items[1].count == 0) {
                        Item item = this.items[1].getItem().t();

                        this.items[1] = item != null ? new ItemStack(item) : null;
                    }
                }
            }
        }

        /* CraftBukkit start - Moved up
        if (this.isBurning() && this.canBurn()) {
            ++this.cookTime;
            if (this.cookTime == 200) {
                this.cookTime = 0;
                this.burn();
                flag1 = true;
            }
        } else {
            this.cookTime = 0;
        }
        // CraftBukkit end */

        if (flag != this.burnTime > 0) {
            flag1 = true;
            BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z);
        }
    }

    if (flag1) {
        this.update();
    }
}
项目:Tweakkit-Server    文件:TileEntityFurnace.java   
public void h() {
    boolean flag = this.burnTime > 0;
    boolean flag1 = false;

    // CraftBukkit start - Use wall time instead of ticks for cooking
    int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
    this.lastTick = MinecraftServer.currentTick;

    // CraftBukkit - moved from below
    if (this.isBurning() && this.canBurn()) {
        this.cookTime += elapsedTicks;
        if (this.cookTime >= 200) {
            this.cookTime %= 200;
            this.burn();
            flag1 = true;
        }
    } else {
        this.cookTime = 0;
    }
    // CraftBukkit end

    if (this.burnTime > 0) {
        this.burnTime -= elapsedTicks; // CraftBukkit - use elapsedTicks in place of constant
    }

    if (!this.world.isStatic) {
        if (this.burnTime != 0 || this.items[1] != null && this.items[0] != null) {
            // CraftBukkit start - Handle multiple elapsed ticks
            if (this.burnTime <= 0 && this.canBurn()) { // CraftBukkit - == to <=
                CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]);

                FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.items[1]));
                this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);

                if (furnaceBurnEvent.isCancelled()) {
                    return;
                }

                this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime();
                this.burnTime += this.ticksForCurrentFuel;
                if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) {
                    // CraftBukkit end
                    flag1 = true;
                    if (this.items[1] != null) {
                        --this.items[1].count;
                        if (this.items[1].count == 0) {
                            Item item = this.items[1].getItem().t();

                            this.items[1] = item != null ? new ItemStack(item) : null;
                        }
                    }
                }
            }

            /* CraftBukkit start - Moved up
            if (this.isBurning() && this.canBurn()) {
                ++this.cookTime;
                if (this.cookTime == 200) {
                    this.cookTime = 0;
                    this.burn();
                    flag1 = true;
                }
            } else {
                this.cookTime = 0;
            }
            */
        }

        if (flag != this.burnTime > 0) {
            flag1 = true;
            BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z);
        }
    }

    if (flag1) {
        this.update();
    }
}
项目:Craft-city    文件:TileEntityFurnace.java   
public void h() {
    boolean flag = this.burnTime > 0;
    boolean flag1 = false;

    // CraftBukkit start - Use wall time instead of ticks for cooking
    int elapsedTicks = Math.max(1, MinecraftServer.currentTick - this.lastTick);
    this.lastTick = MinecraftServer.currentTick;

    // CraftBukkit - moved from below
    if (this.isBurning() && this.canBurn()) {
        this.cookTime += elapsedTicks;
        if (this.cookTime >= 200) {
            this.cookTime %= 200;
            this.burn();
            flag1 = true;
        }
    } else {
        this.cookTime = 0;
    }
    // CraftBukkit end

    if (this.burnTime > 0) {
        this.burnTime -= elapsedTicks; // CraftBukkit
    }

    if (!this.world.isStatic) {
        // CraftBukkit start - Handle multiple elapsed ticks
        if (this.burnTime <= 0 && this.canBurn() && this.items[1] != null) { // CraftBukkit - == to <=
            CraftItemStack fuel = CraftItemStack.asCraftMirror(this.items[1]);

            FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), fuel, fuelTime(this.items[1]));
            this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);

            if (furnaceBurnEvent.isCancelled()) {
                return;
            }

            this.ticksForCurrentFuel = furnaceBurnEvent.getBurnTime();
            this.burnTime += this.ticksForCurrentFuel;
            if (this.burnTime > 0 && furnaceBurnEvent.isBurning()) {
                // CraftBukkit end
                flag1 = true;
                if (this.items[1] != null) {
                    --this.items[1].count;
                    if (this.items[1].count == 0) {
                        Item item = this.items[1].getItem().s();

                        this.items[1] = item != null ? new ItemStack(item) : null;
                    }
                }
            }
        }

        /* CraftBukkit start - Moved up
        if (this.isBurning() && this.canBurn()) {
            ++this.cookTime;
            if (this.cookTime == 200) {
                this.cookTime = 0;
                this.burn();
                flag1 = true;
            }
        } else {
            this.cookTime = 0;
        }
        // CraftBukkit end */

        if (flag != this.burnTime > 0) {
            flag1 = true;
            BlockFurnace.a(this.burnTime > 0, this.world, this.x, this.y, this.z);
        }
    }

    if (flag1) {
        this.update();
    }
}