Search in sources :

Example 1 with TileHatch

use of forestry.farming.gadgets.TileHatch 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 TileHatch

use of forestry.farming.gadgets.TileHatch 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)

Aggregations

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