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;
}
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 });
}
}
Aggregations