Search in sources :

Example 6 with IInventoryAdapter

use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.

the class TileMoistener method hasFuelMin.

public boolean hasFuelMin(float percentage) {
    int max = 0;
    int avail = 0;
    IInventoryAdapter inventory = getInternalInventory();
    for (int i = InventoryMoistener.SLOT_STASH_1; i < InventoryMoistener.SLOT_RESERVOIR_1; i++) {
        if (inventory.getStackInSlot(i).isEmpty()) {
            max += 64;
            continue;
        }
        if (FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(i))) {
            MoistenerFuel res = FuelManager.moistenerResource.get(inventory.getStackInSlot(i));
            if (res.getItem().isItemEqual(inventory.getStackInSlot(i))) {
                max += 64;
                avail += inventory.getStackInSlot(i).getCount();
            }
        }
    }
    return (float) avail / (float) max > percentage;
}
Also used : MoistenerFuel(forestry.api.fuels.MoistenerFuel) IInventoryAdapter(forestry.core.inventory.IInventoryAdapter)

Example 7 with IInventoryAdapter

use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.

the class TileBottler method hasResourcesMin.

@Override
public boolean hasResourcesMin(float percentage) {
    IInventoryAdapter inventory = getInternalInventory();
    ItemStack emptyCan = inventory.getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
    if (emptyCan.isEmpty()) {
        return false;
    }
    return (float) emptyCan.getCount() / (float) emptyCan.getMaxStackSize() > percentage;
}
Also used : IInventoryAdapter(forestry.core.inventory.IInventoryAdapter) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IInventoryAdapter

use of forestry.core.inventory.IInventoryAdapter in project ForestryMC by ForestryMC.

the class TileStampCollector method updateServerSide.

@Override
public void updateServerSide() {
    if (!updateOnInterval(20)) {
        return;
    }
    ItemStack stamp = null;
    IInventoryAdapter inventory = getInternalInventory();
    if (inventory.getStackInSlot(InventoryStampCollector.SLOT_FILTER).isEmpty()) {
        stamp = PostManager.postRegistry.getPostOffice(world).getAnyStamp(1);
    } else {
        ItemStack filter = inventory.getStackInSlot(InventoryStampCollector.SLOT_FILTER);
        if (filter.getItem() instanceof IStamps) {
            stamp = PostManager.postRegistry.getPostOffice(world).getAnyStamp(((IStamps) filter.getItem()).getPostage(filter), 1);
        }
    }
    if (stamp == null) {
        return;
    }
    // Store it.
    InventoryUtil.stowInInventory(stamp, inventory, true, InventoryStampCollector.SLOT_BUFFER_1, InventoryStampCollector.SLOT_BUFFER_COUNT);
}
Also used : IStamps(forestry.api.mail.IStamps) 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