Skip to content

Commit

Permalink
fix: issue with BUE and problems with RS
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Oct 25, 2023
1 parent 1095fce commit 394e39a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -488,16 +492,18 @@ private void updateSignalsOnClient(final List<MainSignalIdentifier> redSignals,
final List<MainSignalIdentifier> 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() {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 394e39a

Please sign in to comment.