Search in sources :

Example 1 with TileFarmPlain

use of forestry.farming.gadgets.TileFarmPlain 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 2 with TileFarmPlain

use of forestry.farming.gadgets.TileFarmPlain in project ForestryMC by ForestryMC.

the class TriggerLowSoil 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) {
    IStatementParameter parameter = null;
    if (parameters.length > 0) {
        parameter = parameters[0];
    }
    if (!(tile instanceof TileHatch)) {
        return false;
    }
    ITileStructure central = ((TileHatch) tile).getCentralTE();
    if (central == null || !(central instanceof TileFarmPlain)) {
        return false;
    }
    if (parameter == null || parameter.getItemStack() == null) {
        return !((TileFarmPlain) central).hasResourcesAmount(threshold);
    } else {
        ItemStack filter = parameter.getItemStack().copy();
        filter.stackSize = threshold;
        return !((TileFarmPlain) central).hasResources(new ItemStack[] { filter });
    }
}
Also used : ITileStructure(forestry.api.core.ITileStructure) IStatementParameter(buildcraft.api.statements.IStatementParameter) TileHatch(forestry.farming.gadgets.TileHatch) ItemStack(net.minecraft.item.ItemStack) TileFarmPlain(forestry.farming.gadgets.TileFarmPlain)

Example 3 with TileFarmPlain

use of forestry.farming.gadgets.TileFarmPlain in project ForestryMC by ForestryMC.

the class GuiHandlerFarming method getServerGuiElement.

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
    if (id >= GuiId.values().length) {
        return null;
    }
    switch(GuiId.values()[id]) {
        case MultiFarmGUI:
            TileFarmPlain tile = (TileFarmPlain) getTileForestry(world, x, y, z);
            Proxies.net.sendToPlayer(new PacketSocketUpdate(PacketIds.SOCKET_UPDATE, x, y, z, tile), player);
            return new ContainerFarm(player.inventory, tile);
        default:
            return null;
    }
}
Also used : ContainerFarm(forestry.farming.gui.ContainerFarm) PacketSocketUpdate(forestry.core.network.PacketSocketUpdate) TileFarmPlain(forestry.farming.gadgets.TileFarmPlain)

Aggregations

TileFarmPlain (forestry.farming.gadgets.TileFarmPlain)3 ITileStructure (forestry.api.core.ITileStructure)2 TileHatch (forestry.farming.gadgets.TileHatch)2 IStatementParameter (buildcraft.api.statements.IStatementParameter)1 TankManager (forestry.core.fluids.TankManager)1 PacketSocketUpdate (forestry.core.network.PacketSocketUpdate)1 ContainerFarm (forestry.farming.gui.ContainerFarm)1 ItemStack (net.minecraft.item.ItemStack)1 FluidTankInfo (net.minecraftforge.fluids.FluidTankInfo)1