Reconnect pipes across chunks when the chunk loads. Fixes #5583 (#5584)

This commit is contained in:
Richard Freimer authored and GitHub committed 2019-07-27 00:36:03 -04:00
1 parent fbdee4e706
commit 403cdaaeba
2 files changed
+26 -11

No files matched your search

@@ -419,6 +419,16 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
* @param newlyEnabledTransmitters The transmitters that are now enabled and were not before.
*/
protected void recheckConnections(byte newlyEnabledTransmitters) {
//If our connectivity changed on a side and it is also a sided pipe, inform it to recheck its connections
//This fixes pipes not reconnecting cross chunk
for (EnumFacing side : EnumFacing.VALUES) {
if (connectionMapContainsSide(newlyEnabledTransmitters, side)) {
TileEntity tileEntity = MekanismUtils.getTileEntity(world, getPos().offset(side));
if (tileEntity instanceof TileEntitySidedPipe) {
((TileEntitySidedPipe) tileEntity).refreshConnections();
}
}
}
}
/**
@@ -113,19 +113,24 @@ public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N, BU
@Override
protected void recheckConnections(byte newlyEnabledTransmitters) {
if (canHaveIncompatibleNetworks() && getTransmitter().hasTransmitterNetwork()) {
//We only need to check if we can have incompatible networks and if we actually have a network
boolean networkUpdated = false;
for (EnumFacing side : EnumFacing.VALUES) {
if (connectionMapContainsSide(newlyEnabledTransmitters, side)) {
//Recheck the side that is now enabled, as we manually merge this
// cannot be simplified to a first match is good enough
networkUpdated |= recheckConnectionPrechecked(side);
if (getTransmitter().hasTransmitterNetwork()) {
if (canHaveIncompatibleNetworks()) {
//We only need to check if we can have incompatible networks and if we actually have a network
boolean networkUpdated = false;
for (EnumFacing side : EnumFacing.VALUES) {
if (connectionMapContainsSide(newlyEnabledTransmitters, side)) {
//Recheck the side that is now enabled, as we manually merge this
// cannot be simplified to a first match is good enough
networkUpdated |= recheckConnectionPrechecked(side);
}
}
if (networkUpdated) {
refreshNetwork();
}
}
if (networkUpdated) {
refreshNetwork();
}
} else {
//If we don't have a transmitter network then recheck connection status both ways
super.recheckConnections(newlyEnabledTransmitters);
}
}