Search in sources :

Example 1 with TankManager

use of forestry.core.fluids.TankManager in project ForestryMC by ForestryMC.

the class TileFarmPlain method createInventory.

protected void createInventory() {
    setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items") {

        @Override
        public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
            if (GuiUtil.isIndexInRange(slotIndex, SLOT_FERTILIZER, SLOT_FERTILIZER_COUNT)) {
                return acceptsAsFertilizer(itemStack);
            } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT)) {
                return acceptsAsGermling(itemStack);
            } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT)) {
                return acceptsAsResource(itemStack);
            } else if (GuiUtil.isIndexInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) {
                Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
                return tankManager.accepts(fluid);
            }
            return false;
        }

        @Override
        public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
            return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT);
        }
    });
    FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
    tankManager = new TankManager(liquidTank);
}
Also used : TileInventoryAdapter(forestry.core.inventory.TileInventoryAdapter) TankManager(forestry.core.fluids.TankManager) Fluid(net.minecraftforge.fluids.Fluid) ItemStack(net.minecraft.item.ItemStack) FilteredTank(forestry.core.fluids.tanks.FilteredTank)

Example 2 with TankManager

use of forestry.core.fluids.TankManager in project ForestryMC by ForestryMC.

the class ContainerFarm method detectAndSendChanges.

@Override
@SuppressWarnings("unchecked")
public void detectAndSendChanges() {
    super.detectAndSendChanges();
    TankManager tankManager = tile.getTankManager();
    if (tankManager != null) {
        tankManager.updateGuiData(this, crafters);
    }
    for (Object crafter : crafters) {
        tile.sendGUINetworkData(this, (ICrafting) crafter);
    }
}
Also used : TankManager(forestry.core.fluids.TankManager)

Example 3 with TankManager

use of forestry.core.fluids.TankManager in project ForestryMC by ForestryMC.

the class ContainerFarm method addCraftingToCrafters.

@Override
public void addCraftingToCrafters(ICrafting iCrafting) {
    super.addCraftingToCrafters(iCrafting);
    TankManager tankManager = tile.getTankManager();
    if (tankManager != null) {
        tankManager.initGuiData(this, iCrafting);
    }
}
Also used : TankManager(forestry.core.fluids.TankManager)

Example 4 with TankManager

use of forestry.core.fluids.TankManager in project ForestryMC by ForestryMC.

the class TriggerLowLiquid method isTriggerActive.

/**
 * Return true if the tile given in parameter activates the trigger, given
 * the parameters.
 */
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters) {
    if (!(tile instanceof TileHatch)) {
        return false;
    }
    ITileStructure central = ((TileHatch) tile).getCentralTE();
    if (central == null || !(central instanceof TileFarmPlain)) {
        return false;
    }
    TankManager tankManager = ((TileFarmPlain) central).getTankManager();
    FluidTankInfo info = tankManager.getTankInfo(0);
    if (info.fluid == null) {
        return true;
    }
    return ((float) info.fluid.amount / info.capacity) <= threshold;
}
Also used : ITileStructure(forestry.api.core.ITileStructure) FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) TankManager(forestry.core.fluids.TankManager) TileHatch(forestry.farming.gadgets.TileHatch) TileFarmPlain(forestry.farming.gadgets.TileFarmPlain)

Example 5 with TankManager

use of forestry.core.fluids.TankManager in project ForestryMC by ForestryMC.

the class ContainerFarm method updateProgressBar.

@Override
public void updateProgressBar(int i, int j) {
    tile.getGUINetworkData(i, j);
    TankManager tankManager = tile.getTankManager();
    if (tankManager != null) {
        tankManager.processGuiUpdate(i, j);
    }
}
Also used : TankManager(forestry.core.fluids.TankManager)

Aggregations

TankManager (forestry.core.fluids.TankManager)5 ITileStructure (forestry.api.core.ITileStructure)1 FilteredTank (forestry.core.fluids.tanks.FilteredTank)1 TileInventoryAdapter (forestry.core.inventory.TileInventoryAdapter)1 TileFarmPlain (forestry.farming.gadgets.TileFarmPlain)1 TileHatch (forestry.farming.gadgets.TileHatch)1 ItemStack (net.minecraft.item.ItemStack)1 Fluid (net.minecraftforge.fluids.Fluid)1 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)1