use of net.minecraftforge.fluids.capability.IFluidHandler in project ImmersiveEngineering by BluSunrize.
the class TileEntityFluidPipe method getAvailableConnectionByte.
public byte getAvailableConnectionByte() {
byte connections = 0;
IFluidTankProperties[] tankInfo;
for (int i = 5; i >= 0; i--) {
// TileEntity con = worldObj.getTileEntity(xCoord+(i==4?-1: i==5?1: 0),yCoord+(i==0?-1: i==1?1: 0),zCoord+(i==2?-1: i==3?1: 0));
EnumFacing dir = EnumFacing.getFront(i);
TileEntity con = worldObj.getTileEntity(getPos().offset(dir));
connections <<= 1;
if (con != null && con.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite())) {
IFluidHandler handler = con.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite());
tankInfo = handler.getTankProperties();
if (tankInfo != null && tankInfo.length > 0)
connections |= 1;
}
}
return connections;
}
use of net.minecraftforge.fluids.capability.IFluidHandler in project ImmersiveEngineering by BluSunrize.
the class TileEntityFluidPipe method getConnectionByte.
public byte getConnectionByte() {
byte connections = 0;
IFluidTankProperties[] tankInfo;
for (int i = 5; i >= 0; i--) {
// TileEntity con = worldObj.getTileEntity(xCoord+(i==4?-1: i==5?1: 0),yCoord+(i==0?-1: i==1?1: 0),zCoord+(i==2?-1: i==3?1: 0));
EnumFacing dir = EnumFacing.getFront(i);
TileEntity con = worldObj.getTileEntity(getPos().offset(dir));
connections <<= 1;
if (sideConfig[i] == 0 && con != null && con.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite())) {
IFluidHandler handler = con.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, dir.getOpposite());
tankInfo = handler.getTankProperties();
if (tankInfo != null && tankInfo.length > 0)
connections |= 1;
}
}
return connections;
}
use of net.minecraftforge.fluids.capability.IFluidHandler in project ImmersiveEngineering by BluSunrize.
the class ItemDrill method onBlockDestroyed.
@Override
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos, EntityLivingBase living) {
if ((double) state.getBlockHardness(world, pos) != 0.0D) {
int dmg = ForgeHooks.isToolEffective(world, pos, stack) ? 1 : 3;
ItemStack head = getHead(stack);
if (head != null) {
if (living instanceof EntityPlayer) {
if (((EntityPlayer) living).capabilities.isCreativeMode)
return true;
((IDrillHead) head.getItem()).afterBlockbreak(stack, head, (EntityPlayer) living);
}
((IDrillHead) head.getItem()).damageHead(head, dmg);
this.setHead(stack, head);
IFluidHandler handler = FluidUtil.getFluidHandler(stack);
handler.drain(1, true);
}
}
return true;
}
use of net.minecraftforge.fluids.capability.IFluidHandler in project Railcraft by Railcraft.
the class TankManager method findNeighbors.
private Collection<IFluidHandler> findNeighbors(AdjacentTileCache cache, Predicate<? super TileEntity> filter, EnumFacing[] sides) {
List<IFluidHandler> targets = new ArrayList<>();
for (EnumFacing side : sides) {
TileEntity tile = cache.getTileOnSide(side);
if (tile == null)
continue;
if (!TANK_FILTER.apply(tile, side.getOpposite()))
continue;
if (!filter.test(tile))
continue;
IFluidHandler tank = FluidTools.getFluidHandler(side.getOpposite(), tile);
if (tank != null)
targets.add(tank);
}
return targets;
}
use of net.minecraftforge.fluids.capability.IFluidHandler in project Railcraft by Railcraft.
the class DetectorTank method testCarts.
@Override
public int testCarts(List<EntityMinecart> carts) {
for (EntityMinecart cart : carts) {
IFluidHandler fluidHandler = FluidTools.getFluidHandler(null, cart);
if (fluidHandler != null) {
AdvancedFluidHandler tank = new AdvancedFluidHandler(fluidHandler);
boolean liquidMatches = false;
Fluid filterFluid = getFilterFluid();
FluidStack tankLiquid = tank.drain(1, false);
if (filterFluid == null)
liquidMatches = true;
else if (Fluids.areEqual(filterFluid, tankLiquid))
liquidMatches = true;
else if (tank.canPutFluid(new FluidStack(filterFluid, 1)))
liquidMatches = true;
boolean quantityMatches = false;
ButtonState state = buttonController.getButtonState();
switch(state) {
case VOID:
quantityMatches = true;
break;
case EMPTY:
if (filterFluid != null && tank.isTankEmpty(filterFluid))
quantityMatches = true;
else if (filterFluid == null && tank.areTanksEmpty())
quantityMatches = true;
break;
case NOT_EMPTY:
if (filterFluid != null && tank.getFluidQty(filterFluid) > 0)
quantityMatches = true;
else if (filterFluid == null && tank.isFluidInTank())
quantityMatches = true;
break;
case FULL:
if (filterFluid != null && tank.isTankFull(filterFluid))
quantityMatches = true;
else if (filterFluid == null && tank.areTanksFull())
quantityMatches = true;
break;
default:
float level = filterFluid != null ? tank.getFluidLevel(filterFluid) : tank.getFluidLevel();
switch(state) {
case ANALOG:
return (int) (FULL_POWER * level);
case QUARTER:
quantityMatches = level >= 0.25f;
break;
case HALF:
quantityMatches = level >= 0.5f;
break;
case MOST:
quantityMatches = level >= 0.75f;
break;
case LESS_THAN_QUARTER:
quantityMatches = level < 0.25f;
break;
case LESS_THAN_HALF:
quantityMatches = level < 0.5f;
break;
case LESS_THAN_MOST:
quantityMatches = level < 0.75f;
break;
case LESS_THAN_FULL:
quantityMatches = level < 1f;
break;
}
}
return liquidMatches && quantityMatches ? FULL_POWER : NO_POWER;
}
}
return NO_POWER;
}
Aggregations