Skip to content

Commit

Permalink
fix: missing UI update; ref: changed SignalConfig back to static
Browse files Browse the repository at this point in the history
  • Loading branch information
Uhutown committed Oct 27, 2024
1 parent ad44661 commit 1c117e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
public class SignalBoxPathway implements IChunkLoadable {

protected final PathwayData data;
protected final SignalConfig config;

protected boolean isBlocked;
protected boolean isAutoPathway = false;
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Class<SignalConfig>> 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()) {
Expand All @@ -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<ConfigProperty> defaultValues = OneSignalPredicateConfigParser.DEFAULTCONFIGS
Expand Down Expand Up @@ -88,15 +84,15 @@ public static void reset(final ResetInfo info) {
});
}

public void loadDisable(final ConfigInfo info) {
public static void loadDisable(final ConfigInfo info) {
final List<ConfigProperty> disableValues = OneSignalPredicateConfigParser.DISABLECONFIGS
.get(info.currentinfo.signal);
if (disableValues != null) {
changeIfPresent(disableValues, info);
}
}

private void changeIfPresent(final List<ConfigProperty> values, final ConfigInfo info) {
private static void changeIfPresent(final List<ConfigProperty> values, final ConfigInfo info) {
loadSignalAndRunTask(info.currentinfo, (stateInfo, oldProperties, _u) -> {
if (info.nextinfo != null) {
loadSignalAndRunTask(info.nextinfo, (nextInfo, nextProperties, _u2) -> {
Expand All @@ -108,7 +104,7 @@ private void changeIfPresent(final List<ConfigProperty> values, final ConfigInfo
});
}

private void changeSignals(final List<ConfigProperty> values, final ConfigInfo info,
private static void changeSignals(final List<ConfigProperty> values, final ConfigInfo info,
final Map<SEProperty, String> oldProperties,
final Map<SEProperty, String> nextProperties) {
final Map<Class<?>, Object> object = new HashMap<>();
Expand All @@ -126,11 +122,10 @@ private void changeSignals(final List<ConfigProperty> values, final ConfigInfo i
});
if (!propertiesToSet.isEmpty()) {
SignalStateHandler.setStates(info.currentinfo, propertiesToSet);
updatePreviousPathway(info.currentinfo);
}
}

private void loadWithoutPredicate(final List<ConfigProperty> values,
private static void loadWithoutPredicate(final List<ConfigProperty> values,
final SignalStateInfo current) {
if (values != null) {
loadSignalAndRunTask(current, (info, oldProperties, _u) -> {
Expand All @@ -142,17 +137,11 @@ private void loadWithoutPredicate(final List<ConfigProperty> 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);
Expand Down

0 comments on commit 1c117e6

Please sign in to comment.