Search in sources :

Example 6 with BlockFluidPipe

use of gregtech.common.pipelike.fluidpipe.BlockFluidPipe in project GregTech by GregTechCE.

the class TileEntityFluidPipeTickable method pushFluidsFromTank.

public static void pushFluidsFromTank(IPipeTile<FluidPipeType, FluidPipeProperties> pipeTile) {
    PooledMutableBlockPos blockPos = PooledMutableBlockPos.retain();
    int blockedConnections = pipeTile.getBlockedConnections();
    BlockFluidPipe blockFluidPipe = (BlockFluidPipe) pipeTile.getPipeBlock();
    for (EnumFacing side : EnumFacing.VALUES) {
        if ((blockedConnections & 1 << side.getIndex()) > 0) {
            // do not dispatch energy to blocked sides
            continue;
        }
        blockPos.setPos(pipeTile.getPipePos()).move(side);
        if (!pipeTile.getPipeWorld().isBlockLoaded(blockPos)) {
            // do not allow cables to load chunks
            continue;
        }
        TileEntity tileEntity = pipeTile.getPipeWorld().getTileEntity(blockPos);
        if (tileEntity == null) {
            // do not emit into multiparts or other fluid pipes
            continue;
        }
        IFluidHandler sourceHandler = pipeTile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
        IFluidHandler receiverHandler = tileEntity.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side.getOpposite());
        if (sourceHandler != null && receiverHandler != null && blockFluidPipe.canPushIntoFluidHandler(pipeTile, tileEntity, sourceHandler, receiverHandler)) {
            GTFluidUtils.transferFluids(sourceHandler, receiverHandler, Integer.MAX_VALUE);
        }
    }
    blockPos.release();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) PooledMutableBlockPos(net.minecraft.util.math.BlockPos.PooledMutableBlockPos) EnumFacing(net.minecraft.util.EnumFacing) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) IFluidHandler(net.minecraftforge.fluids.capability.IFluidHandler)

Aggregations

BlockFluidPipe (gregtech.common.pipelike.fluidpipe.BlockFluidPipe)6 CCRenderState (codechicken.lib.render.CCRenderState)3 Material (gregtech.api.unification.material.type.Material)3 FluidPipeType (gregtech.common.pipelike.fluidpipe.FluidPipeType)3 ItemBlockFluidPipe (gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe)3 FluidPipeProperties (gregtech.common.pipelike.fluidpipe.FluidPipeProperties)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 IVertexOperation (codechicken.lib.render.pipeline.IVertexOperation)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Matrix4 (codechicken.lib.vec.Matrix4)1 Translation (codechicken.lib.vec.Translation)1 Vector3 (codechicken.lib.vec.Vector3)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 BlockMachine (gregtech.api.block.machines.BlockMachine)1 ICoverable (gregtech.api.cover.ICoverable)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 MetaTileEntityHolder (gregtech.api.metatileentity.MetaTileEntityHolder)1 IPipeTile (gregtech.api.pipenet.tile.IPipeTile)1 TileEntityPipeBase (gregtech.api.pipenet.tile.TileEntityPipeBase)1