Search in sources :

Example 1 with IFluidTankProperties

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) };
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) FluidTankProperties(net.minecraftforge.fluids.capability.FluidTankProperties) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 2 with IFluidTankProperties

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) };
}
Also used : IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidTankProperties(net.minecraftforge.fluids.capability.FluidTankProperties) FluidStack(net.minecraftforge.fluids.FluidStack)

Example 3 with IFluidTankProperties

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) EnumFacing(net.minecraft.util.EnumFacing) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 4 with IFluidTankProperties

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) EnumFacing(net.minecraft.util.EnumFacing) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Example 5 with IFluidTankProperties

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;
}
Also used : IFluidTankProperties(net.minecraftforge.fluids.capability.IFluidTankProperties) FluidStack(net.minecraftforge.fluids.FluidStack)

Aggregations

IFluidTankProperties (net.minecraftforge.fluids.capability.IFluidTankProperties)7 FluidStack (net.minecraftforge.fluids.FluidStack)4 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)3 FluidTankProperties (net.minecraftforge.fluids.capability.FluidTankProperties)2 IFluidPipe (blusunrize.immersiveengineering.api.fluid.IFluidPipe)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1