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


Java FurnaceInventory.getFuel方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:24,代码来源:Fuel.java

示例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();
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:23,代码来源:Pump.java

示例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();
    }
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:21,代码来源:FurnaceEndpoint.java

示例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;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:23,代码来源:FurnaceEndpoint.java

示例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;
}
 
开发者ID:CynicalBusiness,项目名称:Mechanization-old,代码行数:13,代码来源:WorldFactory.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.getFuel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。