Skip to content

Commit

Permalink
check old orphan transmitter was valid and remove orphans when invali…
Browse files Browse the repository at this point in the history
…dating
  • Loading branch information
thiakil committed Dec 24, 2024
1 parent aa708cd commit a1ea0e9
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ public static void untrackTransmitter(Transmitter<?, ?, ?> transmitter) {
}

public static void invalidateTransmitter(Transmitter<?, ?, ?> transmitter) {
getInstance().invalidTransmitters.add(transmitter);
TransmitterNetworkRegistry registry = getInstance();
registry.invalidTransmitters.add(transmitter);
Coord4D coord = transmitter.getTileCoord();
Transmitter<?, ?, ?> removed = registry.newOrphanTransmitters.remove(coord);
if (removed != null && removed != transmitter) {
Mekanism.logger.error("Different orphan transmitter was registered at location during removal! {}", coord);
registry.newOrphanTransmitters.put(coord, transmitter);//put it back?
}
}

public static void registerOrphanTransmitter(Transmitter<?, ?, ?> transmitter) {
Expand All @@ -101,7 +108,7 @@ public static void registerOrphanTransmitter(Transmitter<?, ?, ?> transmitter) {
// was in.
Coord4D coord = transmitter.getTileCoord();
Transmitter<?, ?, ?> previous = getInstance().newOrphanTransmitters.put(coord, transmitter);
if (previous != null && previous != transmitter) {
if (previous != null && previous != transmitter && previous.isValid()) {
Mekanism.logger.error("Different orphan transmitter was already registered at location! {}", coord);
}
}
Expand Down

0 comments on commit a1ea0e9

Please sign in to comment.