use of net.minecraftforge.fluids.capability.IFluidTankProperties in project MinecraftForge by MinecraftForge.
the class BlockLiquidWrapper method getTankProperties.
@Override
public IFluidTankProperties[] getTankProperties() {
FluidStack containedStack = null;
IBlockState blockState = world.getBlockState(blockPos);
if (blockState.getBlock() == blockLiquid) {
containedStack = getStack(blockState);
}
return new FluidTankProperties[] { new FluidTankProperties(containedStack, Fluid.BUCKET_VOLUME, false, true) };
}
use of net.minecraftforge.fluids.capability.IFluidTankProperties in project MinecraftForge by MinecraftForge.
the class FluidBlockWrapper method getTankProperties.
@Override
public IFluidTankProperties[] getTankProperties() {
float percentFilled = fluidBlock.getFilledPercentage(world, blockPos);
if (percentFilled < 0) {
percentFilled *= -1;
}
int amountFilled = Math.round(Fluid.BUCKET_VOLUME * percentFilled);
FluidStack fluid = amountFilled > 0 ? new FluidStack(fluidBlock.getFluid(), amountFilled) : null;
return new FluidTankProperties[] { new FluidTankProperties(fluid, Fluid.BUCKET_VOLUME, false, true) };
}
use of net.minecraftforge.fluids.capability.IFluidTankProperties 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.IFluidTankProperties 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.IFluidTankProperties in project Railcraft by Railcraft.
the class AdvancedFluidHandler method getFluidLevel.
public float getFluidLevel() {
int amount = 0;
int capacity = 0;
for (IFluidTankProperties tank : getTankProperties()) {
FluidStack liquid = tank.getContents();
amount += liquid == null ? 0 : liquid.amount;
capacity += tank.getCapacity();
}
return capacity == 0 ? 0 : amount / capacity;
}
Aggregations