SteamWar/BauSystem2.0
Archiviert
12
0

Make tnt only spawn in own region or 100 blocks around you if you are in global region
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-06-11 21:49:40 +02:00
Ursprung 1cfa3058f5
Commit ce2caae9ce
4 geänderte Dateien mit 23 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -229,9 +229,10 @@ public class TNTSimulator {
}
}
Region region = Region.getRegion(p.getLocation());
Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result = new HashMap<>();
for (SimulatorElement element : tntElementList) {
element.locations(result);
element.locations(result, region, p.getLocation());
}
playerShowMode.forEach((player, simulatorEntityShowMode) -> {

Datei anzeigen

@ -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<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result); // Ticks to subtick order to spawning runnable to count of activations
void locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result, Region region, Location location); // Ticks to subtick order to spawning runnable to count of activations
// Observer
default void change() {

Datei anzeigen

@ -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<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result) {
public void locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> 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));

Datei anzeigen

@ -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<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result) {
public void locations(Map<Integer, Map<Integer, Set<Pair<Runnable, Integer>>>> result, Region region, Location location) {
if (disabled) return;
elements.forEach(tntElement -> {
tntElement.locations(result);
tntElement.locations(result, region, location);
});
}