diff --git a/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java b/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java index 7a00dd895..1599e3544 100644 --- a/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java +++ b/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java @@ -65,7 +65,6 @@ private EnumGuiMode(final int id, final boolean unused) { return new UITexture(UISignalBoxTile.SIGNALS); } }); - System.out.println(this.toString() + " ID: " + id); } private EnumGuiMode(final float[] array) { diff --git a/src/main/java/com/troblecodings/signals/signalbox/OtherSignalIdentifier.java b/src/main/java/com/troblecodings/signals/signalbox/OtherSignalIdentifier.java index a25cc9370..f4fefe0c7 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/OtherSignalIdentifier.java +++ b/src/main/java/com/troblecodings/signals/signalbox/OtherSignalIdentifier.java @@ -7,11 +7,13 @@ public class OtherSignalIdentifier extends MainSignalIdentifier { public final boolean isRepeater; + public final boolean isRSSignal; public OtherSignalIdentifier(final Point point, final ModeSet mode, final BlockPos pos, - final boolean isRepeater) { + final boolean isRepeater, final boolean isRSSignal) { super(point, mode, pos); this.isRepeater = isRepeater; + this.isRSSignal = isRSSignal; } @Override @@ -31,6 +33,7 @@ public boolean equals(final Object obj) { if (getClass() != obj.getClass()) return false; final OtherSignalIdentifier other = (OtherSignalIdentifier) obj; - return isRepeater == other.isRepeater && super.equals(obj); + return isRepeater == other.isRepeater && super.equals(obj) + && isRSSignal == other.isRSSignal; } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java index 19e14fca4..775d60e19 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java @@ -131,7 +131,8 @@ private void initalize() { .getEntry(PathEntryType.SIGNAL_REPEATER); distantPosBuilder.put(position, new OtherSignalIdentifier(node.getPoint(), modeSet, position, - repeaterOption.isPresent() && repeaterOption.get())); + repeaterOption.isPresent() && repeaterOption.get(), + mode.equals(EnumGuiMode.RS))); })); } node.getModes().entrySet().stream() @@ -431,6 +432,9 @@ private void setSignals(final SignalStateInfo lastSignal) { } else { position.state = SignalState.RED; } + if (position.isRSSignal) { + position.state = SignalState.GREEN; + } if (position.state.equals(previous)) { return; } else { @@ -488,16 +492,18 @@ private void updateSignalsOnClient(final List redSignals, final List greenSignals) { if (redSignals.isEmpty() && greenSignals.isEmpty()) return; - final SignalBoxTileEntity tile = (SignalBoxTileEntity) world.getBlockEntity(tilePos); - if (tile == null || !tile.isBlocked()) - return; - final WriteBuffer buffer = new WriteBuffer(); - buffer.putEnumValue(SignalBoxNetwork.SET_SIGNALS); - buffer.putByte((byte) redSignals.size()); - redSignals.forEach(signal -> signal.writeNetwork(buffer)); - buffer.putByte((byte) greenSignals.size()); - greenSignals.forEach(signal -> signal.writeNetwork(buffer)); - OpenSignalsMain.network.sendTo(tile.get(0).getPlayer(), buffer); + world.getServer().execute(() -> { + final SignalBoxTileEntity tile = (SignalBoxTileEntity) world.getBlockEntity(tilePos); + if (tile == null || !tile.isBlocked()) + return; + final WriteBuffer buffer = new WriteBuffer(); + buffer.putEnumValue(SignalBoxNetwork.SET_SIGNALS); + buffer.putByte((byte) redSignals.size()); + redSignals.forEach(signal -> signal.writeNetwork(buffer)); + buffer.putByte((byte) greenSignals.size()); + greenSignals.forEach(signal -> signal.writeNetwork(buffer)); + OpenSignalsMain.network.sendTo(tile.get(0).getPlayer(), buffer); + }); } public void resetPathway() { @@ -569,8 +575,10 @@ public void compact(final Point point) { if (current == null) return; final OtherSignalIdentifier identifier = distantSignalPositions - .getOrDefault(position, new OtherSignalIdentifier(point, - new ModeSet(mode, rotation), position, false)); + .getOrDefault(position, + new OtherSignalIdentifier(point, + new ModeSet(mode, rotation), position, false, + mode.equals(EnumGuiMode.RS))); SignalConfig.reset( new ResetInfo(new SignalStateInfo(world, position, current), identifier.isRepeater));