}
@Override
public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer statementContainer, IStatementParameter[] parameters) {
if (tile instanceof IFluidHandler) {
IFluidHandler container = (IFluidHandler) tile;
FluidStack searchedFluid = null;
if (parameters != null && parameters.length >= 1 && parameters[0] != null && parameters[0].getItemStack() != null) {
searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameters[0].getItemStack());
}
if (searchedFluid != null) {
searchedFluid.amount = 1;
}
FluidTankInfo[] liquids = container.getTankInfo(side);
if (liquids == null || liquids.length == 0) {
return false;
}
switch (state) {
case Empty:
for (FluidTankInfo c : liquids) {
if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) {
return false;
}
}
return true;
case Contains:
for (FluidTankInfo c : liquids) {
if (c.fluid != null && c.fluid.amount > 0 && (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid))) {
return true;
}
}
return false;
case Space:
if (searchedFluid == null) {
for (FluidTankInfo c : liquids) {
if (c.fluid == null || c.fluid.amount < c.capacity) {
return true;
}
}
return false;
}
return container.fill(side, searchedFluid, false) > 0;
case Full:
if (searchedFluid == null) {
for (FluidTankInfo c : liquids) {
if (c.fluid == null || c.fluid.amount < c.capacity) {
return false;
}
}
return true;
}
return container.fill(side, searchedFluid, false) <= 0;
}
}
return false;
}