use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.
the class NetworkFinderSolar method loopAll.
private void loopAll(int x, int y, int z, int dirIn) {
BlockVec3 obj = null;
for (int dir = 0; dir < 6; dir++) {
if (dir == dirIn) {
continue;
}
switch(dir) {
case 0:
obj = new BlockVec3(x, y - 1, z);
break;
case 1:
obj = new BlockVec3(x, y + 1, z);
break;
case 2:
obj = new BlockVec3(x, y, z - 1);
break;
case 3:
obj = new BlockVec3(x, y, z + 1);
break;
case 4:
obj = new BlockVec3(x - 1, y, z);
break;
case 5:
obj = new BlockVec3(x + 1, y, z);
break;
}
if (!iterated.contains(obj)) {
iterated.add(obj);
TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(obj.x, obj.y, obj.z));
if (tileEntity instanceof ITransmitter && ((ITransmitter) tileEntity).getNetworkType() == NetworkType.SOLAR_MODULE) {
found.add((ITransmitter) tileEntity);
loopAll(obj.x, obj.y, obj.z, dir ^ 1);
}
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.
the class SolarModuleNetwork method refreshWithChecks.
/**
* Refresh validity of each conductor in the network
*/
public void refreshWithChecks() {
Iterator<ITransmitter> it = this.transmitters.iterator();
while (it.hasNext()) {
ITransmitter transmitter = it.next();
if (transmitter == null) {
it.remove();
continue;
}
TileEntity tile = (TileEntity) transmitter;
World world = tile.getWorld();
// Remove any transmitters in unloaded chunks
if (tile.isInvalid() || world == null || !world.isBlockLoaded(tile.getPos())) {
it.remove();
continue;
}
if (transmitter != world.getTileEntity(tile.getPos())) {
it.remove();
continue;
}
if (transmitter.getNetwork() != this) {
transmitter.setNetwork(this);
transmitter.onNetworkChanged();
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.
the class TileEntityFluidTransmitter method refresh.
@Override
public void refresh() {
if (!this.world.isRemote) {
this.adjacentConnections = null;
BlockVec3 thisVec = new BlockVec3(this);
for (EnumFacing side : EnumFacing.VALUES) {
TileEntity tileEntity = thisVec.getTileEntityOnSide(this.world, side);
if (tileEntity != null) {
if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider && ((INetworkProvider) tileEntity).hasNetwork()) {
if (!(tileEntity instanceof ITransmitter) || (((ITransmitter) tileEntity).canConnect(side.getOpposite(), ((ITransmitter) tileEntity).getNetworkType()))) {
if (!this.hasNetwork()) {
this.setNetwork(((INetworkProvider) tileEntity).getNetwork());
((FluidNetwork) this.getNetwork()).addTransmitter(this);
((FluidNetwork) this.getNetwork()).onTransmitterAdded(this);
} else if (this.hasNetwork() && !this.getNetwork().equals(((INetworkProvider) tileEntity).getNetwork())) {
this.setNetwork((IGridNetwork) this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()));
}
}
}
}
}
this.getNetwork().refresh();
}
}
Aggregations