Java 类org.bukkit.inventory.FurnaceInventory 实例源码

项目:StarQuestCode    文件:Tool.java   
/**
 * Expends a use of the given toolType from the furnaceInventory. If the
 * furnaceInventory's smelting slot is empty, attempts to retrieve a new
 * tool from the given supplyInventory. Returns true if successful.
 * 
 * @param furnaceInventory The furnace from which the tool should be used.
 * @param toolType A predicate specifying what tool should be used.
 * @param supplyInventory Supply inventory to search in case the furnaceInventory is empty. May be null to not search.
 * @return True if a single use was expended for the given tool type.
 */
public static boolean useInFurnace(FurnaceInventory furnaceInventory, Predicate<ItemStack> toolType, Inventory supplyInventory) {
    ItemStack tool = furnaceInventory.getSmelting();
    if (tool == null || tool.getType() == Material.AIR) {
        // Try and find a tool in the chest.
        InventoryManager manager = new InventoryManager(supplyInventory);
        if (supplyInventory == null || !manager.find(toolType))
            return false;
        tool = manager.get();
        furnaceInventory.setSmelting(tool);
        manager.decrement();
        tool = furnaceInventory.getSmelting();
    } else if (!toolType.apply(tool))
        return false;

    // Use up durability.
    short newDurability = (short) (tool.getDurability() + 1);
    if (newDurability >= tool.getType().getMaxDurability()) {
        furnaceInventory.setSmelting(null);
    } else {
        tool.setDurability(newDurability);
    }
    return true;
}
项目:StarQuestCode    文件:Fuel.java   
/**
 * Consumes fuel from the given Furnace.
 * 
 * @param furnace
 *            The furnace to consume fuel from
 * @return The burn time of the fuel consumed. Returns 0 on failure.
 */
public static int consume(final Furnace furnace) {
    try {
        FurnaceInventory furnaceInventory = furnace.getInventory();
        ItemStack fuelStack = furnaceInventory.getFuel();
        if (fuelStack == null)
            return 0;
        int burnTime = burnTime(fuelStack.getType().getId());
        if (burnTime > 0) {
            fuelStack.setAmount(fuelStack.getAmount() - 1);
            furnaceInventory.setFuel(fuelStack);
        }
        return burnTime;
    } catch (Exception e) {
        return 0;
    }
}
项目:StarQuestCode    文件:Pump.java   
/**
 * Adds a drain block to the furnace's smelt slot for the deconstruction of
 * a drain.
 * 
 * @param data The data value of the tube material to check.
 * @return True if a drain block item could be added to the furnace smelt
 *         slot.
 */
boolean putDrainItem(byte data) {
    FurnaceInventory inventory = ((Furnace) anchor.getRelative(backward).getBlock().getState()).getInventory();
    ItemStack item = inventory.getSmelting();
    if (item == null) {
        inventory.setSmelting(new ItemStack(tubeMaterial, 1, data));
        return true;
    } else if (item.getType() == tubeMaterial && item.getDurability() == data) {
        int amount = item.getAmount();
        if (amount < tubeMaterial.getMaxStackSize()) {
            item.setAmount(amount + 1);
            inventory.setSmelting(item);
            return true;
        }
    }
    return false;
}
项目:StarQuestCode    文件:Pump.java   
private Stage stop() {
    if (tube.size() == 0)
        return null;
    // Check which mode the pump should operate in.
    FurnaceInventory inventory = ((Furnace) anchor.getRelative(backward).getBlock().getState()).getInventory();
    ItemStack item = inventory.getFuel();
    if (item != null && item.getType() == filledBucketMaterial) {
        if (filledBucketMaterial == Material.WATER_BUCKET && anchor.getWorld().getEnvironment() == World.Environment.NETHER && !player.hasPermission("machinapump.nether-water")) {
            player.sendMessage("You do not have permission to pour water with a pump in the nether.");
            return new Retract();
        } else if (filledBucketMaterial == Material.LAVA_BUCKET && !player.hasPermission("machinapump.lava.fill")) {
            player.sendMessage("You do not have permission to pour lava with a pump.");
            return new Retract();
        }
        return new Fill();
    }
    if (liquidMaterial == Material.LAVA && !player.hasPermission("machinapump.lava.drain")) {
        player.sendMessage("You do not have permission to drain lava with a pump.");
        return new Retract();
    }
    return new Drain();
}
项目:StarQuestCode    文件:FurnaceRelay.java   
private boolean doSend(BlockLocation fromFurnace) throws PipelineException, PacketTypeUnsupportedException {
    FurnaceInventory inventory = (((Furnace) fromFurnace.getBlock().getState()).getInventory());
    ItemStack item = inventory.getResult();
    if (item == null || item.getType() == Material.AIR)
        return false;
    ItemStack toSend = new ItemStack(item);
    toSend.setAmount(1);

    if (pipeline.sendPacket(toSend)) {
        item.setAmount(item.getAmount() - 1);
        inventory.setResult(item);
        age = 0;
        return true;
    }
    return false;
}
项目:StarQuestCode    文件:FurnaceEndpoint.java   
/**
 * Handles a sending inventory for the furnace at the given location. Does
 * not check if the location has a valid furnace.<br>
 * Fuels: Added to the fuel slot if there is room.<br>
 * Items that can be burnt: Added to the burn slot.
 * 
 * @param location
 * @param inventory
 * @return True if the inventory was changed.
 */
public boolean handle(Inventory inventory) {
    FurnaceInventory furnaceInventory = ((Furnace) location.getBlock().getState()).getInventory();
    if (furnaceInventory == inventory) {
        return false;
    }
    updateLevels();

    if (fuelAmount < 2) {
        if (restockFuel(furnaceInventory, inventory))
            return true;
        return restockSmelting(furnaceInventory, inventory);
    } else {
        if (restockSmelting(furnaceInventory, inventory))
            return true;
        return restockFuel(furnaceInventory, inventory);
    }
}
项目:StarQuestCode    文件:FurnaceEndpoint.java   
/**
 * Updates the status of the furnace to the current amount of fuel and
 * smelting items.
 */
private final void updateLevels() {
    FurnaceInventory inventory = (((Furnace) location.getBlock().getState()).getInventory());
    final ItemStack fuelItem = inventory.getFuel();
    if (fuelItem == null || fuelItem.getType() == Material.AIR) {
        fuelAmount = 0;
    } else {
        fuelAmount = fuelItem.getAmount();
    }

    final ItemStack smeltItem = inventory.getSmelting();
    if (smeltItem == null || smeltItem.getType() == Material.AIR) {
        smeltingAmount = 0;
    } else {
        smeltingAmount = smeltItem.getAmount();
    }
}
项目:StarQuestCode    文件:FurnaceEndpoint.java   
private static boolean restockFuel(FurnaceInventory furnaceInventory, Inventory inventory) {
    InventoryManager manager = new InventoryManager(inventory);
    ItemStack fuelItem = furnaceInventory.getFuel();
    if (fuelItem == null || fuelItem.getType() == Material.AIR) {
        if (!manager.find(isFuelItem))
            return false;
        fuelItem = new ItemStack(manager.get());
        fuelItem.setAmount(1);
        furnaceInventory.setFuel(fuelItem);
        manager.decrement();
        return true;
    } else if (manager.findItemType(fuelItem)) {
        int amount = fuelItem.getAmount();
        if (amount < fuelItem.getMaxStackSize()) {
            fuelItem.setAmount(amount + 1);
            furnaceInventory.setFuel(fuelItem);
            manager.decrement();
            return true;
        }
    }
    return false;
}
项目:StarQuestCode    文件:FurnaceEndpoint.java   
private static boolean restockSmelting(FurnaceInventory furnaceInventory, Inventory inventory) {
    InventoryManager manager = new InventoryManager(inventory);
    ItemStack smeltItem = furnaceInventory.getSmelting();
    if (smeltItem == null || smeltItem.getType() == Material.AIR) {
        if (!manager.find(burnableItem))
            return false;
        smeltItem = new ItemStack(manager.get());
        smeltItem.setAmount(1);
        furnaceInventory.setSmelting(smeltItem);
        manager.decrement();
        return true;
    } else if (manager.findItemType(smeltItem)) {
        int amount = smeltItem.getAmount();
        if (amount < smeltItem.getMaxStackSize()) {
            smeltItem.setAmount(amount + 1);
            furnaceInventory.setSmelting(smeltItem);
            manager.decrement();
            return true;
        }
    }
    return false;
}
项目:StarQuestCode    文件:Pump.java   
public Stage run() {
    int size = tube.size();
    if (size == maxLength)
        return stop();

    BlockLocation target = anchor.getRelative(forward, size + 1);

    if (!target.isEmptyForCollision())
        return stop();

    // Try to take a drain block from the furnace.
    FurnaceInventory inventory = ((Furnace) anchor.getRelative(backward).getBlock().getState()).getInventory();
    ItemStack item = inventory.getSmelting();
    if (item != null && item.getType() == tubeMaterial) {
        byte data = (byte) item.getDurability();
        // Before taking, we have to simulate whether we can actually
        // place the block.
        if (!EventSimulator.blockPlace(target, tubeMaterial.getId(), (byte) 0, target.getRelative(backward, size), player))
            return stop();

        int newAmount = item.getAmount() - 1;
        if (newAmount < 1) {
            inventory.setSmelting(null);
        } else {
            item.setAmount(newAmount);
            inventory.setSmelting(item);
        }
        target.setTypeIdAndData(tubeMaterial.getId(), data, true);
        tube.add(target);
        return this;
    }
    return stop();
}
项目:StarQuestCode    文件:Planter.java   
private void useTool() throws NoToolException {
    if (!useTool)
        return;
    FurnaceInventory furnaceInventory = ((Furnace) furnace.getBlock().getState()).getInventory();
    if (!Tool.useInFurnace(furnaceInventory, planterTool, chestInventory())) {
        throw new NoToolException();
    }
}
项目:McMMOPlus    文件:InventoryListener.java   
private Block processInventoryOpenOrCloseEvent(Inventory inventory) {
    if (!(inventory instanceof FurnaceInventory)) {
        return null;
    }

    Furnace furnace = (Furnace) inventory.getHolder();

    if (furnace == null || furnace.getBurnTime() != 0) {
        return null;
    }

    return furnace.getBlock();
}
项目:Mechanization-old    文件:WorldFactory.java   
public static boolean takeFurnaceFuel(Furnace f, int fuel){
    FurnaceInventory inv = f.getInventory();
    if (inv.getFuel().getAmount()>fuel){
        ItemStack is = inv.getFuel();
        is.setAmount(is.getAmount()-fuel);
        return true;
    } else if (inv.getFuel().getAmount()==fuel){
        inv.setFuel(new ItemStack(Material.AIR));
        return true;
    }
    return false;
}
项目:Mechanization-old    文件:WorldFactory.java   
public boolean validFurnacesForRecipe(MechaFactoryRecipe recipe, int fuelOffset){
    if (getFurnaces().size()==0) return false;
    for (Furnace fur : getFurnaces()){
        FurnaceInventory inv = fur.getInventory();
        if (!(inv.getSmelting()==null || inv.getSmelting().getType()==Material.AIR)) return false; 
        ItemStack fuelIS = fur.getInventory().getFuel();
        if (fuelIS==null || fuelIS.getType()!=Material.COAL || fuelIS.getAmount()<recipe.getRecipe().getFuelCost()-fuelOffset) return false;
    }
    return true;
}
项目:EpicQuest    文件:InventoryDragListener.java   
@EventHandler
public void onInventoryMoveItem(InventoryClickEvent event){
    if(event.getInventory().getType().equals(InventoryType.FURNACE) && event.getRawSlot() == 0){

        Player player = (Player)event.getWhoClicked();
        FurnaceInventory fi = (FurnaceInventory)event.getInventory();
        EpicSystem.furnaceList.put(fi.getHolder().getLocation(), EpicSystem.getEpicPlayer(player));
    }
}
项目:Uranium    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Skript    文件:ExprFurnaceSlot.java   
public FurnaceEventSlot(final Event e, final FurnaceInventory invi) {
    super(invi, slot);
    this.e = e;
}
项目:ThermosRebased    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:MinecraftPlugins    文件:FurnaceBurn.java   
public FurnaceBurn(Block block) {

        super(false);

        org.bukkit.block.Furnace furnace = (org.bukkit.block.Furnace) block.getState();

        if (block.hasMetadata(metaFurn)) {

            FurnaceInventory furnaceInventory = furnace.getInventory();

            furnaceInventory.setFuel(null);
            furnaceInventory.setSmelting(null);
            furnaceInventory.setResult(null);

            block.removeMetadata(metaFurn, getPlugin());
            removeMetadata(block.getLocation());

            block.setType(Material.FURNACE);

        }

    }
项目:Thermos    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:KCauldron    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:CauldronGit    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Cauldron-Old    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Cauldron-Reloaded    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:FFoKC    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:CraftBukkit    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Craftbukkit    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Almura-Server    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Tweakkit-Server    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Cauldron    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Pore    文件:PoreFurnace.java   
@Override
public FurnaceInventory getInventory() {
    return PoreFurnaceInventory.of(getTileEntity().getInventory());
}
项目:SpigotSource    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:Craft-city    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:MCPBukkit    文件:CraftFurnace.java   
public FurnaceInventory getInventory() {
    return new CraftInventoryFurnace(furnace);
}
项目:MinecraftPlugins    文件:Furnace.java   
public Furnace(Block block, Player player) {

        super(false);

        org.bukkit.block.Furnace furnace = (org.bukkit.block.Furnace) block.getState();

        String noChange = "Furnace has contents. Not changing.";

        FurnaceInventory furnaceInventory = furnace.getInventory();

        if (furnaceInventory.getFuel() != null || furnaceInventory.getSmelting() != null
                || furnaceInventory.getResult() != null) {
            getCommonString().messageSend(player, noChange);
            return;
        }

        furnaceInventory.setFuel(getFurnaceFuel());
        furnaceInventory.setSmelting(getFurnaceSmelt());
        furnaceInventory.setResult(null);

        furnace.setCookTime((short) Integer.MAX_VALUE);
        furnace.setBurnTime((short) Integer.MAX_VALUE);

        furnace.setType(Material.BURNING_FURNACE);

        block.setMetadata(metaFurn, new FixedMetadataValue(getPlugin(), true));
        saveMetadata(block.getLocation(), metaFurn);

    }
项目:Thermos-Bukkit    文件:Furnace.java   
public FurnaceInventory getInventory();
项目:CauldronGit    文件:Furnace.java   
public FurnaceInventory getInventory();
项目:Cauldron    文件:Furnace.java   
public FurnaceInventory getInventory();
项目:Cauldron    文件:Furnace.java   
public FurnaceInventory getInventory();
项目:Cauldron    文件:Furnace.java   
public FurnaceInventory getInventory();