use of micdoodle8.mods.galacticraft.api.transmission.tile.INetworkConnection in project Galacticraft by micdoodle8.
the class ChunkPowerHandler method onChunkLoad.
@SubscribeEvent
public void onChunkLoad(ChunkEvent.Load event) {
if (!event.world.isRemote && event.getChunk() != null) {
try {
ArrayList<Object> tileList = Lists.newArrayList();
tileList.addAll(event.getChunk().getTileEntityMap().values());
for (Object o : tileList) {
if (o instanceof TileEntity) {
TileEntity tile = (TileEntity) o;
if (tile instanceof INetworkConnection) {
((INetworkConnection) tile).refresh();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
if (ConfigManagerCore.retrogenOil && GCCoreUtil.getDimensionID(event.world) == 0) {
EventHandlerGC.retrogenOil(event.world, event.getChunk());
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.tile.INetworkConnection in project Galacticraft by micdoodle8.
the class BlockEnclosed method onNeighborBlockChange.
@Override
public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block block) {
int metadata = state.getBlock().getMetaFromState(state);
final TileEntity tileEntity = world.getTileEntity(pos);
if (metadata == EnumEnclosedBlockType.TE_CONDUIT.getMeta()) {
super.onNeighborBlockChange(world, pos, state, block);
} else if (metadata == EnumEnclosedBlockType.OXYGEN_PIPE.getMeta()) {
super.onNeighborBlockChange(world, pos, state, block);
if (tileEntity instanceof INetworkConnection) {
((INetworkConnection) tileEntity).refresh();
}
} else if (metadata <= 6) {
super.onNeighborBlockChange(world, pos, state, block);
if (CompatibilityManager.isIc2Loaded() && tileEntity != null) {
try {
if (onBlockNeighbourChangeIC2a != null) {
onBlockNeighbourChangeIC2a.invoke(tileEntity, block);
} else if (onBlockNeighbourChangeIC2b != null) {
onBlockNeighbourChangeIC2b.invoke(tileEntity, block, pos);
}
return;
} catch (Exception ignore) {
}
}
} else if (metadata <= 12) {
if (CompatibilityManager.isBCraftTransportLoaded()) {
if (blockPipeBC != null) {
try {
blockPipeBC.onNeighborBlockChange(world, pos, state, block);
} catch (Exception e) {
e.printStackTrace();
}
return;
}
}
super.onNeighborBlockChange(world, pos, state, block);
} else if (metadata <= EnumEnclosedBlockType.ME_CABLE.getMeta()) {
super.onNeighborBlockChange(world, pos, state, block);
if (CompatibilityManager.isAppEngLoaded()) {
world.markBlockForUpdate(pos);
}
} else if (metadata <= EnumEnclosedBlockType.ALUMINUM_WIRE.getMeta()) {
super.onNeighborBlockChange(world, pos, state, block);
if (tileEntity instanceof IConductor) {
((IConductor) tileEntity).refresh();
}
} else if (metadata <= EnumEnclosedBlockType.ALUMINUM_WIRE_HEAVY.getMeta()) {
super.onNeighborBlockChange(world, pos, state, block);
if (tileEntity instanceof IConductor) {
((IConductor) tileEntity).refresh();
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.tile.INetworkConnection in project Galacticraft by micdoodle8.
the class BlockTransmitter method onNeighborBlockChange.
@Override
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
TileEntity tile = worldIn.getTileEntity(pos);
this.setBlockBoundsBasedOnState(worldIn, pos);
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(EnumSimplePacket.C_UPDATE_WIRE_BOUNDS, GCCoreUtil.getDimensionID(worldIn), new Object[] { pos }), new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(worldIn), pos.getX(), pos.getY(), pos.getZ(), 10.0D));
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tile instanceof INetworkConnection) {
((INetworkConnection) tile).refresh();
}
}
use of micdoodle8.mods.galacticraft.api.transmission.tile.INetworkConnection 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();
}
}
}
Aggregations