diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupChooserGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupChooserGui.java index fabbfac3..10396677 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupChooserGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupChooserGui.java @@ -63,6 +63,9 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui { } })); } + inventory.addCloseCallback(clickType -> { + back.open(); + }); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupSettingsGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupSettingsGui.java index 873011f9..e9439ce9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupSettingsGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorGroupSettingsGui.java @@ -140,7 +140,6 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }); inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> { - // TODO: Change X Anvil GUI })); inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> { simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0); @@ -153,7 +152,6 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }); inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> { - // TODO: Change Y Anvil GUI })); inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> { simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0); @@ -166,7 +164,6 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }); inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> { - // TODO: Change Z Anvil GUI })); inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> { simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstoneGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstoneGui.java index 81cc7f4e..1475cee4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstoneGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstoneGui.java @@ -119,7 +119,6 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui 0) { RedstoneSubPhase subPhase = data.get(index - 1); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java index 70a1bf9c..27901b09 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorRedstonePhaseSettingsGui.java @@ -74,17 +74,37 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); })); + int index = redstoneElement.getPhases().indexOf(redstone); + int min; + if (index > 0) { + RedstonePhase previous = redstoneElement.getPhases().get(index - 1); + min = previous.getTickOffset() + previous.getLifetime() + 1; + } else { + min = 0; + } + + int maxLifetime; + int maxOffset; + if (index < redstoneElement.getPhases().size() - 1) { + RedstonePhase next = redstoneElement.getPhases().get(index + 1); + maxLifetime = next.getTickOffset() - redstone.getTickOffset() - 1; + maxOffset = next.getTickOffset() - redstone.getLifetime() - 1; + } else { + maxLifetime = Integer.MAX_VALUE - 5; + maxOffset = Integer.MAX_VALUE - 5; + } + //Tick Offset int offset = redstone.getTickOffset(); - inventory.setItem(10, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { - redstone.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1)); + inventory.setItem(10, SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { + redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1))); SimulatorWatcher.update(simulator); }); SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> { new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> { if (integer < 0) return false; - redstone.setTickOffset(integer); + redstone.setTickOffset(Math.min(Math.max(integer, min), maxOffset)); SimulatorWatcher.update(simulator); return true; }, this).setItem(Material.REPEATER).open(); @@ -92,22 +112,22 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui { offsetItem.getItemStack().setAmount(Math.max(1, Math.min(offset, 64))); inventory.setItem(19, offsetItem); - inventory.setItem(28, SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { - redstone.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1))); + inventory.setItem(28, SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> { + redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1))); SimulatorWatcher.update(simulator); }); //Lifetime int lifetime = redstone.getLifetime(); - inventory.setItem(11, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { - redstone.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1)); + inventory.setItem(11, SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> { + redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1))); SimulatorWatcher.update(simulator); }); SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> { new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> { if (integer < 0) return false; - redstone.setLifetime(integer); + redstone.setLifetime(Math.min(integer, maxLifetime)); SimulatorWatcher.update(simulator); return true; }, this).setItem(Material.CLOCK).open(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTSettingsGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTSettingsGui.java index 20f695e4..1dcf005c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTSettingsGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorTNTSettingsGui.java @@ -33,7 +33,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -public class SimulatorTNTSettingsGui extends SimulatorBaseGui { // TODO: Anvil GUI's! +public class SimulatorTNTSettingsGui extends SimulatorBaseGui { private final TNTElement tnt; private final SimulatorBaseGui back;