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