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 c38fcb62..baae7afd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -229,9 +229,10 @@ public class TNTSimulator { } } + Region region = Region.getRegion(p.getLocation()); Map>>> result = new HashMap<>(); for (SimulatorElement element : tntElementList) { - element.locations(result); + element.locations(result, region, p.getLocation()); } playerShowMode.forEach((player, simulatorEntityShowMode) -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java index 501eb1fd..68651379 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.simulator.tnt; import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; import de.steamwar.inventory.SWItem; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -47,7 +49,7 @@ public interface SimulatorElement { void hide(SimulatorEntityShowMode showMode); SWItem menu(Player p); - void locations(Map>>> result); // Ticks to subtick order to spawning runnable to count of activations + void locations(Map>>> result, Region region, Location location); // Ticks to subtick order to spawning runnable to count of activations // Observer default void change() { 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 011c4445..5bab7b68 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 @@ -24,11 +24,15 @@ import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.OrderUtils; import de.steamwar.bausystem.features.simulator.SimulatorStorage; import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Position; import de.steamwar.inventory.SWItem; import lombok.Getter; import lombok.Setter; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -163,12 +167,20 @@ public class TNTElement implements SimulatorElement { } @Override - public void locations(Map>>> result) { + public void locations(Map>>> result, Region region, Location radius) { if (disabled) return; + Location location = getPosition().toLocation(SimulatorStorage.WORLD); + if (region.isGlobal() && location.distanceSquared(radius) > 10000) { + return; + } + if (!region.inRegion(location, RegionType.NORMAL, RegionExtensionType.NORMAL)) { + return; + } + result.computeIfAbsent(getTickOffset(), ignore -> new HashMap<>()) .computeIfAbsent(OrderUtils.order(order), ignore -> new HashSet<>()) .add(new Pair<>(() -> { - SimulatorStorage.WORLD.spawn(getPosition().toLocation(SimulatorStorage.WORLD), TNTPrimed.class, tntPrimed -> { + SimulatorStorage.WORLD.spawn(location, TNTPrimed.class, tntPrimed -> { tntPrimed.setFuseTicks(fuseTicks); if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0)); if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0)); 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 9ae10591..d2344ff5 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 @@ -21,9 +21,11 @@ package de.steamwar.bausystem.features.simulator.tnt; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; import de.steamwar.inventory.SWItem; import lombok.Getter; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -137,10 +139,10 @@ public class TNTGroup implements SimulatorElement { } @Override - public void locations(Map>>> result) { + public void locations(Map>>> result, Region region, Location location) { if (disabled) return; elements.forEach(tntElement -> { - tntElement.locations(result); + tntElement.locations(result, region, location); }); }