From e67d9fd63a5c73a26b6e8d79f06b912b5afb2aa3 Mon Sep 17 00:00:00 2001 From: Cedric Date: Mon, 20 Nov 2023 11:18:59 +0100 Subject: [PATCH] fix: issue with PathwayRequester --- .../signals/guis/PathwayRequesterGui.java | 33 ++++++++++++++----- .../PathwayRequesterTileEntity.java | 3 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/troblecodings/signals/guis/PathwayRequesterGui.java b/src/main/java/com/troblecodings/signals/guis/PathwayRequesterGui.java index 2d591a6b8..3b37619c3 100644 --- a/src/main/java/com/troblecodings/signals/guis/PathwayRequesterGui.java +++ b/src/main/java/com/troblecodings/signals/guis/PathwayRequesterGui.java @@ -2,6 +2,7 @@ import com.troblecodings.core.I18Wrapper; import com.troblecodings.core.WriteBuffer; +import com.troblecodings.guilib.ecs.DrawUtil.DisableIntegerable; import com.troblecodings.guilib.ecs.DrawUtil.SizeIntegerables; import com.troblecodings.guilib.ecs.GuiBase; import com.troblecodings.guilib.ecs.GuiElements; @@ -48,15 +49,27 @@ private void initOwn() { inner.add(GuiElements.createSpacerV(20)); final IIntegerable start = SizeIntegerables.of("StartPoint", - container.validStarts.size(), e -> container.validStarts.get(e).toShortString()); + container.validStarts.size(), e -> { + if (e == -1) + return "Disabled"; + return container.validStarts.get(e).toShortString(); + }); final IIntegerable end = SizeIntegerables.of("EndPoint", - container.validStarts.size(), e -> container.validEnds.get(e).toShortString()); + container.validStarts.size(), e -> { + if (e == -1) + return "Disabled"; + return container.validEnds.get(e).toShortString(); + }); if (!container.validStarts.isEmpty()) { - inner.add(GuiElements.createEnumElement(start, e -> { + inner.add(GuiElements.createEnumElement(new DisableIntegerable<>(start), e -> { + if (e == -1) { + container.start = new Point(-1, -1); + return; + } container.start = container.validStarts.get(e); - }, container.start != null ? container.start.equals(new Point()) ? 0 - : container.validStarts.indexOf(container.start) : 0)); + }, container.start != null ? container.start.equals(new Point(-1, -1)) ? -1 + : container.validStarts.indexOf(container.start) : -1)); } else { final UIEntity infoLabelEntity = new UIEntity(); infoLabelEntity.setInheritWidth(true); @@ -68,10 +81,14 @@ private void initOwn() { } if (!container.validEnds.isEmpty()) { - inner.add(GuiElements.createEnumElement(end, e -> { + inner.add(GuiElements.createEnumElement(new DisableIntegerable<>(end), e -> { + if (e == -1) { + container.end = new Point(-1, -1); + return; + } container.end = container.validEnds.get(e); - }, container.end != null ? container.end.equals(new Point()) ? 0 - : container.validEnds.indexOf(container.end) : 0)); + }, container.end != null ? container.end.equals(new Point(-1, -1)) ? -1 + : container.validEnds.indexOf(container.end) : -1)); } else { final UIEntity infoLabelEntity = new UIEntity(); infoLabelEntity.setInheritWidth(true); diff --git a/src/main/java/com/troblecodings/signals/tileentitys/PathwayRequesterTileEntity.java b/src/main/java/com/troblecodings/signals/tileentitys/PathwayRequesterTileEntity.java index 76b0989b1..c4d7bb614 100644 --- a/src/main/java/com/troblecodings/signals/tileentitys/PathwayRequesterTileEntity.java +++ b/src/main/java/com/troblecodings/signals/tileentitys/PathwayRequesterTileEntity.java @@ -22,7 +22,8 @@ public class PathwayRequesterTileEntity extends SyncableTileEntity implements ILinkableTile, IChunkLoadable { private BlockPos linkedSignalBox; - private Map.Entry pathway = Maps.immutableEntry(new Point(), new Point()); + private Map.Entry pathway = Maps.immutableEntry(new Point(-1, -1), + new Point(-1, -1)); public PathwayRequesterTileEntity(final TileEntityInfo info) { super(info);