當前位置: 首頁>>代碼示例>>Java>>正文


Java Furnace.getInventory方法代碼示例

本文整理匯總了Java中org.bukkit.block.Furnace.getInventory方法的典型用法代碼示例。如果您正苦於以下問題:Java Furnace.getInventory方法的具體用法?Java Furnace.getInventory怎麽用?Java Furnace.getInventory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.Furnace的用法示例。


在下文中一共展示了Furnace.getInventory方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: consume

import org.bukkit.block.Furnace; //導入方法依賴的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: initializeInventory

import org.bukkit.block.Furnace; //導入方法依賴的package包/類
/**
 * Initializes the inventory for this factory
 */
//Due to non-destructable factories this will not have been called on reconstructed factories
//however I am unable to find a use for this method in the current code, so it doesn't
//seem to be an issue right now, maybe  the calls in the constructor should be gotten rid of
//all methods that get the inventory reinitialize the contents.
public void initializeInventory()
{
	switch(factoryType)
	{
	case PRODUCTION:
		Chest chestBlock = (Chest)factoryInventoryLocation.getBlock().getState();
		factoryInventory = chestBlock.getInventory();
		Furnace furnaceBlock = (Furnace)factoryPowerSourceLocation.getBlock().getState();
		factoryPowerInventory = furnaceBlock.getInventory();
		break;
	default:
		break;
	}
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:22,代碼來源:FactoryObject.java

示例3: takeFurnaceFuel

import org.bukkit.block.Furnace; //導入方法依賴的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

示例4: validFurnacesForRecipe

import org.bukkit.block.Furnace; //導入方法依賴的package包/類
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;
}
 
開發者ID:CynicalBusiness,項目名稱:Mechanization-old,代碼行數:11,代碼來源:WorldFactory.java

示例5: getPowerSourceInventory

import org.bukkit.block.Furnace; //導入方法依賴的package包/類
/**
 * Returns the power Source inventory, updates it aswell.
 */
public Inventory getPowerSourceInventory()
{
	Furnace furnaceBlock = (Furnace)factoryPowerSourceLocation.getBlock().getState();
	factoryPowerInventory = furnaceBlock.getInventory();
	return factoryPowerInventory;
}
 
開發者ID:gmlaxfanatic,項目名稱:FactoryMod,代碼行數:10,代碼來源:FactoryObject.java


注:本文中的org.bukkit.block.Furnace.getInventory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。