本文整理汇总了Java中org.bukkit.inventory.FurnaceInventory.getFuel方法的典型用法代码示例。如果您正苦于以下问题:Java FurnaceInventory.getFuel方法的具体用法?Java FurnaceInventory.getFuel怎么用?Java FurnaceInventory.getFuel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.FurnaceInventory
的用法示例。
在下文中一共展示了FurnaceInventory.getFuel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: consume
import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
/**
* 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;
}
}
示例2: stop
import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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();
}
示例3: updateLevels
import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
/**
* 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();
}
}
示例4: restockFuel
import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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;
}
示例5: takeFurnaceFuel
import org.bukkit.inventory.FurnaceInventory; //导入方法依赖的package包/类
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;
}
示例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);
}