当前位置: 首页>>代码示例>>Java>>正文


Java FurnaceInventory.setSmelting方法代码示例

本文整理汇总了Java中org.bukkit.inventory.FurnaceInventory.setSmelting方法的典型用法代码示例。如果您正苦于以下问题:Java FurnaceInventory.setSmelting方法的具体用法?Java FurnaceInventory.setSmelting怎么用?Java FurnaceInventory.setSmelting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.inventory.FurnaceInventory的用法示例。


在下文中一共展示了FurnaceInventory.setSmelting方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: useInFurnace

import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:34,代码来源:Tool.java

示例2: putDrainItem

import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:25,代码来源:Pump.java

示例3: restockSmelting

import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:23,代码来源:FurnaceEndpoint.java

示例4: run

import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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();
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:34,代码来源:Pump.java

示例5: FurnaceBurn

import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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);

        }

    }
 
开发者ID:Ullarah,项目名称:MinecraftPlugins,代码行数:23,代码来源:FurnaceBurn.java

示例6: Furnace

import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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);

    }
 
开发者ID:Ullarah,项目名称:MinecraftPlugins,代码行数:30,代码来源:Furnace.java


注:本文中的org.bukkit.inventory.FurnaceInventory.setSmelting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。