use of micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter in project Galacticraft by micdoodle8.
the class FluidNetwork method split.
@Override
public void split(IBufferTransmitter<FluidStack> splitPoint) {
if (splitPoint instanceof TileEntity) {
this.pipes.remove(splitPoint);
/**
* Loop through the connected blocks and attempt to see if there are
* connections between the two points elsewhere.
*/
TileEntity[] connectedBlocks = splitPoint.getAdjacentConnections();
for (TileEntity connectedBlockA : connectedBlocks) {
if (connectedBlockA instanceof INetworkConnection) {
for (final TileEntity connectedBlockB : connectedBlocks) {
if (connectedBlockA != connectedBlockB && connectedBlockB instanceof INetworkConnection) {
Pathfinder finder = new PathfinderChecker(((TileEntity) splitPoint).getWorld(), (INetworkConnection) connectedBlockB, NetworkType.FLUID, splitPoint);
finder.init(new BlockVec3(connectedBlockA));
if (finder.results.size() > 0) {
for (BlockVec3 node : finder.closedSet) {
TileEntity nodeTile = node.getTileEntity(((TileEntity) splitPoint).getWorld());
if (nodeTile instanceof INetworkProvider) {
if (nodeTile != splitPoint) {
((INetworkProvider) nodeTile).setNetwork(this);
}
}
}
} else {
/**
* The connections A and B are not connected
* anymore. Give both of them a new network.
*/
FluidNetwork newNetwork = new FluidNetwork();
for (BlockVec3 node : finder.closedSet) {
TileEntity nodeTile = node.getTileEntity(((TileEntity) splitPoint).getWorld());
if (nodeTile instanceof IBufferTransmitter) {
if (nodeTile != splitPoint) {
newNetwork.pipes.add((IBufferTransmitter<FluidStack>) nodeTile);
newNetwork.pipesAdded.add((IBufferTransmitter<FluidStack>) nodeTile);
newNetwork.onTransmitterAdded((IBufferTransmitter<FluidStack>) nodeTile);
this.pipes.remove(nodeTile);
}
}
}
newNetwork.refresh();
newNetwork.register();
}
}
}
}
}
if (this.pipes.isEmpty()) {
this.unregister();
} else {
this.updateCapacity();
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter in project Galacticraft by micdoodle8.
the class TileEntityFluidTransmitter method update.
@Override
public void update() {
if (!this.worldObj.isRemote) {
if (!this.validated) {
TickHandlerServer.oxygenTransmitterUpdates.add(this);
this.validated = true;
}
Block blockType = this.getBlockType();
if (blockType instanceof BlockFluidPipe && ((BlockFluidPipe) blockType).getMode() == BlockFluidPipe.EnumPipeMode.PULL) {
TileEntity[] tiles = OxygenUtil.getAdjacentFluidConnections(this);
for (EnumFacing side : EnumFacing.VALUES) {
TileEntity sideTile = tiles[side.ordinal()];
if (sideTile != null && !(sideTile instanceof IBufferTransmitter) && sideTile instanceof IFluidHandler) {
IFluidHandler handler = (IFluidHandler) sideTile;
FluidStack received = handler.drain(side.getOpposite(), this.pullAmount, false);
if (received != null && received.amount != 0) {
handler.drain(side.getOpposite(), this.fill(EnumFacing.DOWN, received, true), true);
}
}
}
}
}
super.update();
}
Aggregations