From eefe92309de042d0cad4d43a21caec9d5e60bb05 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Tue, 2 Apr 2024 22:59:40 +0200 Subject: [PATCH] Fixed #226 Added text input for simulator group --- .../simulator/data/SimulatorGroup.java | 18 ++++++++++++++ .../gui/SimulatorGroupSettingsGui.java | 24 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorGroup.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorGroup.java index 8031dd1c..4e96c452 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorGroup.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/data/SimulatorGroup.java @@ -69,6 +69,24 @@ public final class SimulatorGroup { }); } + public void moveToX(double x) { + elements.forEach(simulatorElement -> { + simulatorElement.getPosition().setX(x); + }); + } + + public void moveToY(double y) { + elements.forEach(simulatorElement -> { + simulatorElement.getPosition().setX(y); + }); + } + + public void moveToZ(double z) { + elements.forEach(simulatorElement -> { + simulatorElement.getPosition().setX(z); + }); + } + public SWItem toItem(Player player, InvCallback groupCallback, InvCallback itemCallback) { if (elements.size() == 1) { return elements.get(0).toItem(player, itemCallback); 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 0a66e21d..8c871526 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 @@ -168,6 +168,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }); inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> { + new SimulatorAnvilGui<>(player, "X", "", Double::parseDouble, number -> { + if(!allTNT){ + number = (double) Math.round(number); + } + simulatorGroup.moveToX(number); + SimulatorWatcher.update(simulator); + return true; + }, this).setItem(Material.PAPER).open(); })); 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); @@ -180,6 +188,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }); inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> { + new SimulatorAnvilGui<>(player, "Y", "", Double::parseDouble, number -> { + if(!allTNT){ + number = (double) Math.round(number); + } + simulatorGroup.moveToY(number); + SimulatorWatcher.update(simulator); + return true; + }, this).setItem(Material.PAPER).open(); })); 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); @@ -192,6 +208,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui { SimulatorWatcher.update(simulator); }); inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> { + new SimulatorAnvilGui<>(player, "Z", "", Double::parseDouble, number -> { + if(!allTNT){ + number = (double) Math.round(number); + } + simulatorGroup.moveToZ(number); + SimulatorWatcher.update(simulator); + return true; + }, this).setItem(Material.PAPER).open(); })); 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);