Search in sources :

Example 1 with IInventoryAdapter

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();
}
Also used : IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IInventoryAdapter

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;
}
Also used : IInventoryAdapter(forestry.core.inventory.IInventoryAdapter)

Example 3 with IInventoryAdapter

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();
    }
}
Also used : IFabricatorSmeltingRecipe(forestry.api.recipes.IFabricatorSmeltingRecipe) FluidStack(net.minecraftforge.fluids.FluidStack) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack)

Example 4 with IInventoryAdapter

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;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack) IFabricatorRecipe(forestry.api.recipes.IFabricatorRecipe) Nullable(javax.annotation.Nullable)

Example 5 with IInventoryAdapter

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;
}
Also used : MoistenerFuel(forestry.api.fuels.MoistenerFuel) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IInventoryAdapter (forestry.core.inventory.IInventoryAdapter)8 ItemStack (net.minecraft.item.ItemStack)6 MoistenerFuel (forestry.api.fuels.MoistenerFuel)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 IStamps (forestry.api.mail.IStamps)1 IFabricatorRecipe (forestry.api.recipes.IFabricatorRecipe)1 IFabricatorSmeltingRecipe (forestry.api.recipes.IFabricatorSmeltingRecipe)1 Nullable (javax.annotation.Nullable)1