use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.
the class TileEnginePeat method addAsh.
private void addAsh(int amount) {
ashProduction += amount;
if (ashProduction < ashForItem) {
return;
}
// If we have reached the necessary amount, we need to add ash
int wasteSlot = getFreeWasteSlot();
if (wasteSlot >= 0) {
IInventoryAdapter inventory = getInternalInventory();
ItemStack wasteStack = inventory.getStackInSlot(wasteSlot);
if (wasteStack.isEmpty()) {
inventory.setInventorySlotContents(wasteSlot, ModuleCore.getItems().ash.getItemStack());
} else {
wasteStack.grow(1);
}
}
// Reset
ashProduction = 0;
// try to dump stash
dumpStash();
}
use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.
the class TileEnginePeat method hasFuelMin.
@Override
public boolean hasFuelMin(float percentage) {
int fuelSlot = this.getFuelSlot();
if (fuelSlot < 0) {
return false;
}
IInventoryAdapter inventory = getInternalInventory();
return (float) inventory.getStackInSlot(fuelSlot).getCount() / (float) inventory.getStackInSlot(fuelSlot).getMaxStackSize() > percentage;
}
use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.
the class TileFabricator method trySmelting.
private void trySmelting() {
IInventoryAdapter inventory = getInternalInventory();
ItemStack smeltResource = inventory.getStackInSlot(InventoryFabricator.SLOT_METAL);
if (smeltResource.isEmpty()) {
return;
}
IFabricatorSmeltingRecipe smelt = FabricatorSmeltingRecipeManager.findMatchingSmelting(smeltResource);
if (smelt == null || smelt.getMeltingPoint() > heat) {
return;
}
FluidStack smeltFluid = smelt.getProduct();
if (moltenTank.fillInternal(smeltFluid, false) == smeltFluid.amount) {
this.decrStackSize(InventoryFabricator.SLOT_METAL, 1);
moltenTank.fillInternal(smeltFluid, true);
meltingPoint = smelt.getMeltingPoint();
}
}
use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.
the class TileFabricator method getRecipe.
@Nullable
private RecipePair getRecipe() {
IInventoryAdapter inventory = getInternalInventory();
ItemStack plan = inventory.getStackInSlot(InventoryFabricator.SLOT_PLAN);
FluidStack liquid = moltenTank.getFluid();
RecipePair<IFabricatorRecipe> recipePair = FabricatorRecipeManager.findMatchingRecipe(plan, craftingInventory);
IFabricatorRecipe recipe = recipePair.getRecipe();
if (liquid != null && recipe != null && !liquid.containsFluid(recipe.getLiquid())) {
return RecipePair.EMPTY;
}
return recipePair;
}
use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.
the class TileMoistener method getNextResourceSlot.
private int getNextResourceSlot(int startSlot, int endSlot) {
// Let's look for a new resource to put into the working slot.
int stage = -1;
int resourceSlot = -1;
IInventoryAdapter inventory = getInternalInventory();
for (int i = startSlot; i < endSlot; i++) {
ItemStack slotStack = inventory.getStackInSlot(i);
if (slotStack.isEmpty()) {
continue;
}
if (!FuelManager.moistenerResource.containsKey(slotStack)) {
continue;
}
MoistenerFuel res = FuelManager.moistenerResource.get(slotStack);
if (stage < 0 || res.getStage() < stage) {
stage = res.getStage();
resourceSlot = i;
}
}
return resourceSlot;
}
Aggregations