本文整理匯總了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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}