From 1c117e6c7a3aa6be69a4c2a093d29e7e13dad871 Mon Sep 17 00:00:00 2001 From: Cedric Date: Sun, 27 Oct 2024 21:33:11 +0100 Subject: [PATCH] fix: missing UI update; ref: changed SignalConfig back to static --- .../signalbox/InterSignalBoxPathway.java | 1 + .../signals/signalbox/SignalBoxPathway.java | 10 +++----- .../signalbox/config/SignalConfig.java | 25 ++++++------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/troblecodings/signals/signalbox/InterSignalBoxPathway.java b/src/main/java/com/troblecodings/signals/signalbox/InterSignalBoxPathway.java index 6d1302b13..1d1d0f83a 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/InterSignalBoxPathway.java +++ b/src/main/java/com/troblecodings/signals/signalbox/InterSignalBoxPathway.java @@ -211,6 +211,7 @@ public boolean tryBlock(final BlockPos position) { pathwayToBlock = (InterSignalBoxPathway) pw; pathwayToBlock.setPathStatus(EnumPathUsage.BLOCKED); pathwayToBlock.updateTrainNumber(trainNumber); + otherGrid.updateToNet(pathwayToBlock); }); } return result; diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java index 3d84acc1d..1bf9e7432 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java @@ -43,7 +43,6 @@ public class SignalBoxPathway implements IChunkLoadable { protected final PathwayData data; - protected final SignalConfig config; protected boolean isBlocked; protected boolean isAutoPathway = false; @@ -58,7 +57,6 @@ public void setTile(final SignalBoxTileEntity tile) { } public SignalBoxPathway(final PathwayData data) { - this.config = new SignalConfig(this); this.data = data; this.originalFirstPoint = new Point(data.getFirstPoint()); updatePathwayToAutomatic(); @@ -205,7 +203,7 @@ protected void setSignals(final SignalStateInfo lastSignal) { if (first == null) return; final SignalStateInfo firstInfo = new SignalStateInfo(world, startSignal.pos, first); - config.change(new ConfigInfo(firstInfo, lastSignal, data)); + SignalConfig.change(new ConfigInfo(firstInfo, lastSignal, data)); updatePreSignals(); } final SignalBoxPathway next = getNextPathway(); @@ -225,9 +223,9 @@ protected void setSignals(final SignalStateInfo lastSignal) { new SignalStateInfo(world, position.pos, current), lastSignal, data, position.isRepeater); if (position.guiMode.equals(EnumGuiMode.HP)) { - config.loadDisable(info); + SignalConfig.loadDisable(info); } else { - config.change(info); + SignalConfig.change(info); } }); updateSignalStates(); @@ -247,7 +245,7 @@ private void updatePreSignals() { final Signal current = SignalBoxHandler.getSignal(identifier, posIdent.pos); if (current == null) return; - config.change( + SignalConfig.change( new ConfigInfo(new SignalStateInfo(tile.getWorld(), posIdent.pos, current), firstInfo, data, posIdent.isRepeater)); }); diff --git a/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java b/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java index 1de9eaa57..87daa4a87 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java +++ b/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java @@ -18,20 +18,16 @@ import com.troblecodings.signals.handler.SignalStateHandler; import com.troblecodings.signals.handler.SignalStateInfo; import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; -import com.troblecodings.signals.signalbox.SignalBoxPathway; public final class SignalConfig { private static final LoadHolder> LOAD_HOLDER = new LoadHolder<>( SignalConfig.class); - private final SignalBoxPathway pathway; - - public SignalConfig(final SignalBoxPathway pathway) { - this.pathway = pathway; + private SignalConfig() { } - public void change(final ConfigInfo info) { + public static void change(final ConfigInfo info) { final Signal currentSignal = info.currentinfo.signal; if (info.type.equals(PathType.NORMAL)) { if (info.nextinfo != null && info.nextinfo.isValid()) { @@ -55,7 +51,7 @@ public void change(final ConfigInfo info) { } } - private void loadDefault(final ConfigInfo info) { + private static void loadDefault(final ConfigInfo info) { if (!info.currentinfo.isValid()) return; final List defaultValues = OneSignalPredicateConfigParser.DEFAULTCONFIGS @@ -88,7 +84,7 @@ public static void reset(final ResetInfo info) { }); } - public void loadDisable(final ConfigInfo info) { + public static void loadDisable(final ConfigInfo info) { final List disableValues = OneSignalPredicateConfigParser.DISABLECONFIGS .get(info.currentinfo.signal); if (disableValues != null) { @@ -96,7 +92,7 @@ public void loadDisable(final ConfigInfo info) { } } - private void changeIfPresent(final List values, final ConfigInfo info) { + private static void changeIfPresent(final List values, final ConfigInfo info) { loadSignalAndRunTask(info.currentinfo, (stateInfo, oldProperties, _u) -> { if (info.nextinfo != null) { loadSignalAndRunTask(info.nextinfo, (nextInfo, nextProperties, _u2) -> { @@ -108,7 +104,7 @@ private void changeIfPresent(final List values, final ConfigInfo }); } - private void changeSignals(final List values, final ConfigInfo info, + private static void changeSignals(final List values, final ConfigInfo info, final Map oldProperties, final Map nextProperties) { final Map, Object> object = new HashMap<>(); @@ -126,11 +122,10 @@ private void changeSignals(final List values, final ConfigInfo i }); if (!propertiesToSet.isEmpty()) { SignalStateHandler.setStates(info.currentinfo, propertiesToSet); - updatePreviousPathway(info.currentinfo); } } - private void loadWithoutPredicate(final List values, + private static void loadWithoutPredicate(final List values, final SignalStateInfo current) { if (values != null) { loadSignalAndRunTask(current, (info, oldProperties, _u) -> { @@ -142,17 +137,11 @@ private void loadWithoutPredicate(final List values, }); if (!propertiesToSet.isEmpty()) { SignalStateHandler.setStates(current, propertiesToSet); - updatePreviousPathway(current); } }); } } - private void updatePreviousPathway(final SignalStateInfo info) { - // info.world.getMinecraftServer().addScheduledTask(() -> - // pathway.updatePrevious()); - } - private static void loadSignalAndRunTask(final SignalStateInfo info, final SignalStateListener task) { final boolean isSignalLoaded = SignalStateHandler.isSignalLoaded(info);