use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.
the class TileEntityFluidTransmitter method setNetwork.
@Override
public void setNetwork(IGridNetwork network) {
if (this.network == network) {
return;
}
if (this.worldObj.isRemote && this.network != null) {
FluidNetwork fluidNetwork = (FluidNetwork) this.network;
fluidNetwork.removeTransmitter(this);
if (fluidNetwork.getTransmitters().isEmpty()) {
fluidNetwork.unregister();
}
}
this.network = network;
if (this.worldObj.isRemote && this.network != null) {
((FluidNetwork) this.network).pipes.add(this);
}
}
use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.
the class TileEntityAluminumWireSwitch method refresh.
@Override
public void refresh() {
boolean newDisableConnections = this.disableConnections();
if (newDisableConnections && !this.disableConnections) {
this.disableConnections = newDisableConnections;
if (!this.worldObj.isRemote) {
this.disConnect();
}
} else if (!newDisableConnections && this.disableConnections) {
this.disableConnections = newDisableConnections;
if (!this.worldObj.isRemote) {
// Force a full network refresh of this and conductors either side
this.setNetwork(null);
}
}
if (!this.worldObj.isRemote) {
this.adjacentConnections = null;
if (!this.disableConnections) {
this.getNetwork().refresh();
BlockVec3 thisVec = new BlockVec3(this);
for (EnumFacing side : EnumFacing.VALUES) {
if (this.canConnect(side, NetworkType.POWER)) {
TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, side);
if (tileEntity instanceof TileBaseConductor && ((TileBaseConductor) tileEntity).canConnect(side.getOpposite(), NetworkType.POWER)) {
IGridNetwork otherNet = ((INetworkProvider) tileEntity).getNetwork();
if (!this.getNetwork().equals(otherNet)) {
if (!otherNet.getTransmitters().isEmpty()) {
otherNet.merge(this.getNetwork());
}
}
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.
the class TileBaseConductor method refresh.
@Override
public void refresh() {
if (!this.worldObj.isRemote) {
this.adjacentConnections = null;
this.getNetwork().refresh();
BlockVec3 thisVec = new BlockVec3(this);
for (EnumFacing side : EnumFacing.VALUES) {
TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, side);
if (tileEntity instanceof TileBaseConductor && ((TileBaseConductor) tileEntity).canConnect(side.getOpposite(), NetworkType.POWER)) {
IGridNetwork otherNet = ((INetworkProvider) tileEntity).getNetwork();
if (!this.getNetwork().equals(otherNet)) {
if (!otherNet.getTransmitters().isEmpty()) {
otherNet.merge(this.getNetwork());
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.
the class TileEntityFluidTransmitter method refresh.
@Override
public void refresh() {
if (!this.worldObj.isRemote) {
this.adjacentConnections = null;
BlockVec3 thisVec = new BlockVec3(this);
for (EnumFacing side : EnumFacing.VALUES) {
TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, 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