diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index caa3af54..d6a5fb2a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -56,6 +56,7 @@ public class SimulatorCursor { if (result.getHitEntity() != null) { List elements = tntSimulator.getEntity(result.getHitEntity()); + System.out.println(elements); cursor = new REntityServer(); RFallingBlockEntity entity = new RFallingBlockEntity(cursor, (elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition()).toLocation(WORLD), Material.TNT); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java index 0b7b312b..a549e0a2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java @@ -178,7 +178,7 @@ public class SimulatorStorage implements Enable, Disable { if (content.isEmpty()) continue; TNTSimulator tntSimulator = new TNTSimulator(); for (YAPIONObject element : content.streamObject().collect(Collectors.toList())) { - tntSimulator.getTntElementList().add(new TNTElement(element, tntSimulator.getEntityServer())); + tntSimulator.getTntElementList().add(new TNTElement(element, null, tntSimulator.getEntityServer())); } tntSimulators.put(newName, tntSimulator); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index f7c2ff71..1f51b10b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -67,7 +67,7 @@ public class TNTSimulator { if (element.containsKey("elements", YAPIONType.ARRAY)) { tntElementList.add(new TNTGroup(element, entityServer)); } else { - tntElementList.add(new TNTElement(element, entityServer)); + tntElementList.add(new TNTElement(element, null, entityServer)); } } } @@ -164,7 +164,7 @@ public class TNTSimulator { return; } - TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result), entityServer); + TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result), null, entityServer); tntElementList.add(tntElement); TNTElementGUI.open(player, tntElement, null); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java index bfd0312b..875482a4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java @@ -341,15 +341,13 @@ public class TNTElementGUI { int tickOffset = tntElement.getOwnTickOffset(); TNTGroup tntGroup = new TNTGroup(vector); tntGroup.setTickOffset(tickOffset); - tntElement.setTickOffset(0); - tntElement.getOwnPosition().setX(0); - tntElement.getOwnPosition().setY(0); - tntElement.getOwnPosition().setZ(0); tntGroup.add(tntElement); + tntElement.setTickOffset(0); + tntElement.setPosition(new Vector(0, 0, 0)); tntSimulator.getTntElementList().add(tntGroup); // Add new TNT - TNTElement newElement = new TNTElement(new Vector(0, 0, 0), tntSimulator.getEntityServer()); + TNTElement newElement = new TNTElement(new Vector(0, 0, 0), tntGroup, tntSimulator.getEntityServer()); newElement.setTickOffset(1); tntGroup.add(newElement); @@ -365,7 +363,7 @@ public class TNTElementGUI { inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; Vector vector = tntElement.getOwnPosition().clone(); - TNTElement newElement = new TNTElement(vector, tntSimulator.getEntityServer()); + TNTElement newElement = new TNTElement(vector, null, tntSimulator.getEntityServer()); if (tntElement.hasParent()) { newElement.setTickOffset(tntElement.getOwnTickOffset() + 1); tntElement.getParent().add(newElement); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java index a9df556e..e7b358a9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java @@ -71,20 +71,18 @@ public class TNTElement implements SimulatorElement { private Material material = Material.TNT; private boolean disabled = false; - public TNTElement(Vector position, REntityServer entityServer) { + public TNTElement(Vector position, TNTGroup tntGroup, REntityServer entityServer) { this.entityServer = entityServer; + this.tntGroup = tntGroup; this.position = position; - this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT); - this.entity.setNoGravity(true); + initEntity(); } - public TNTElement(YAPIONObject yapionObject, REntityServer entityServer) { + public TNTElement(YAPIONObject yapionObject, TNTGroup tntGroup, REntityServer entityServer) { this.entityServer = entityServer; + this.tntGroup = tntGroup; this.position = new Vector(yapionObject.getDoubleOrDefault("x", yapionObject.getDoubleOrDefault("positionX", 0)), yapionObject.getDoubleOrDefault("y", yapionObject.getDoubleOrDefault("positionY", 0)), yapionObject.getDoubleOrDefault("z", yapionObject.getDoubleOrDefault("positionZ", 0))); this.disabled = yapionObject.getBooleanOrDefault("disabled", false); - this.entity = new RFallingBlockEntity(entityServer, position.toLocation(WORLD), Material.TNT); - this.entity.setNoGravity(true); - this.entity.setInvisible(disabled); this.fuseTicks = yapionObject.getIntOrDefault("fuseTicks", 80); this.count = yapionObject.getIntOrDefault("count", 1); this.tickOffset = yapionObject.getIntOrDefault("tickOffset", 0); @@ -93,6 +91,12 @@ public class TNTElement implements SimulatorElement { this.zVelocity = yapionObject.getBooleanOrDefault("zVelocity", false); this.order = Material.valueOf(yapionObject.getStringOrDefault("order", yapionObject.getBooleanOrDefault("comparator", false) ? Material.COMPARATOR.name() : Material.REPEATER.name())); this.material = Material.valueOf(yapionObject.getStringOrDefault("material", Material.TNT.name())); + initEntity(); + } + + private void initEntity() { + this.entity = new RFallingBlockEntity(entityServer, getPosition().toLocation(WORLD), Material.TNT); + this.entity.setNoGravity(true); _updatePosition(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java index 9485cefa..f3327578 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java @@ -59,8 +59,7 @@ public class TNTGroup implements SimulatorElement { this.disabled = yapionObject.getBooleanOrDefault("disabled", false); YAPIONArray elements = yapionObject.getArrayOrDefault("elements", new YAPIONArray()); for (YAPIONObject element : elements.streamObject().collect(Collectors.toList())) { - TNTElement tntElement = new TNTElement(element, entityServer); - tntElement.tntGroup = this; + TNTElement tntElement = new TNTElement(element, this, entityServer); this.elements.add(tntElement); tntElement._updatePosition(); }