本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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);
}