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();
}
Aggregations