SteamWar/BauSystem2.0
Archiviert
12
0

Add seamless changing and showing and hiding
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-06-09 19:42:11 +02:00
Ursprung 6ed13702d4
Commit 8b351fe871
14 geänderte Dateien mit 136 neuen und 62 gelöschten Zeilen

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.shared.BaseEntity15; import de.steamwar.bausystem.shared.BaseEntity15;
import de.steamwar.bausystem.shared.ReferenceCounter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,7 +28,7 @@ import org.bukkit.util.Vector;
public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity { public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity {
private ReferenceCounter referenceCounter = new ReferenceCounter(); private boolean printed = false;
public SimulatorEntity15(World world, Vector position, boolean highlight) { public SimulatorEntity15(World world, Vector position, boolean highlight) {
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
@ -40,9 +39,8 @@ public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulator
@Override @Override
public void display(Player player) { public void display(Player player) {
if (referenceCounter.increment() > 0) { if (printed) return;
return; printed = true;
}
sendEntity(player); sendEntity(player);
} }
@ -55,9 +53,9 @@ public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulator
@Override @Override
public boolean hide(Player player, boolean force) { public boolean hide(Player player, boolean force) {
if (!force && referenceCounter.decrement() > 0) { if (!printed) return false;
return false; printed = false;
}
sendEntityDestroy(player); sendEntityDestroy(player);
die(); die();

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.shared.BaseEntity18; import de.steamwar.bausystem.shared.BaseEntity18;
import de.steamwar.bausystem.shared.ReferenceCounter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,7 +28,7 @@ import org.bukkit.util.Vector;
public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity { public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity {
private ReferenceCounter referenceCounter = new ReferenceCounter(); private boolean printed = false;
public SimulatorEntity18(World world, Vector position, boolean highlight) { public SimulatorEntity18(World world, Vector position, boolean highlight) {
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
@ -45,9 +44,8 @@ public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulator
@Override @Override
public void display(Player player) { public void display(Player player) {
if (referenceCounter.increment() > 0) { if (printed) return;
return; printed = true;
}
sendEntity(player); sendEntity(player);
} }
@ -60,9 +58,8 @@ public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulator
@Override @Override
public boolean hide(Player player, boolean force) { public boolean hide(Player player, boolean force) {
if (!force && referenceCounter.decrement() > 0) { if (!printed) return false;
return false; printed = false;
}
sendEntityDestroy(player); sendEntityDestroy(player);
ag(); ag();

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.entities;
import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity;
import de.steamwar.bausystem.shared.BaseEntity19; import de.steamwar.bausystem.shared.BaseEntity19;
import de.steamwar.bausystem.shared.ReferenceCounter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,7 +28,7 @@ import org.bukkit.util.Vector;
public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulatorEntity { public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulatorEntity {
private ReferenceCounter referenceCounter = new ReferenceCounter(); private boolean printed = false;
public SimulatorEntity19(World world, Vector position, boolean highlight) { public SimulatorEntity19(World world, Vector position, boolean highlight) {
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
@ -45,9 +44,8 @@ public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulator
@Override @Override
public void display(Player player) { public void display(Player player) {
if (referenceCounter.increment() > 0) { if (printed) return;
return; printed = true;
}
sendEntity(player); sendEntity(player);
} }
@ -60,9 +58,8 @@ public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulator
@Override @Override
public boolean hide(Player player, boolean force) { public boolean hide(Player player, boolean force) {
if (!force && referenceCounter.decrement() > 0) { if (!printed) return false;
return false; printed = false;
}
sendEntityDestroy(player); sendEntityDestroy(player);
ag(); ag();

Datei anzeigen

@ -501,12 +501,15 @@ SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eregion type§7 of the current region
UNSIGN_HELP=§8/§eunsign §8- §7Make a signed book writable again UNSIGN_HELP=§8/§eunsign §8- §7Make a signed book writable again
# Simulator # Simulator
SIMULATORN_NO_SIM_IN_HAND = §cNo simulator item selected SIMULATOR_HELP = §8/§esimulator §8-§7 Gives you the simulator wand
SIMULATORN_GUI_SELECT_SIM = Simulator selection SIMULATOR_CHANGE_HELP = §8/§esimulator change §8-§7 Change your simulator wand selection
SIMULATOR_CREATE_HELP = §8/§esimulator create §8[§7name§8] §8-§7 Create a new simulator
SIMULATOR_NO_SIM_IN_HAND = §cNo simulator item selected
SIMULATOR_GUI_SELECT_SIM = Simulator selection
SIMULATOR_NAME_ALREADY_EXISTS = §cSimulator already exists
SIMULATOR_CREATE = §aSimulator created
SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator
SIMULATOR_HELP = §8/§esimulator §8-§7 Gives you the simulator wand
SIMULATOR_START_HELP = §8/§esimulator start §8-§7 Starts the simulation SIMULATOR_START_HELP = §8/§esimulator start §8-§7 Starts the simulation
SIMULATOR_GUI_HELP = §8/§esimulator gui §8-§7 Opens the simulator's gui SIMULATOR_GUI_HELP = §8/§esimulator gui §8-§7 Opens the simulator's gui
SIMULATOR_DELETE_HELP = §8/§esimulator delete §8-§7 Deletes all TNT SIMULATOR_DELETE_HELP = §8/§esimulator delete §8-§7 Deletes all TNT

Datei anzeigen

@ -42,19 +42,30 @@ public class SimulatorCommand extends SWCommand {
@Register(description = "SIMULATOR_HELP") @Register(description = "SIMULATOR_HELP")
public void genericCommand(@Guard Player p) { public void genericCommand(@Guard Player p) {
SimulatorCursor.hide(p, null);
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p)); SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
} }
@Register(value = "change", description = "") @Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
public void changeCommand(@Guard Player p) { public void change(@Guard Player p) {
ItemStack itemStack = p.getInventory().getItemInMainHand(); ItemStack itemStack = p.getInventory().getItemInMainHand();
if (!ItemUtils.isItem(itemStack, "simulator")) { if (!ItemUtils.isItem(itemStack, "simulator")) {
BauSystem.MESSAGE.send("SIMULATORN_NO_SIM_IN_HAND", p); BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
return; return;
} }
SimulatorSelectionGUI.open(p, itemStack); SimulatorSelectionGUI.open(p, itemStack);
} }
@Register(value = "create", description = "SIMULATOR_CREATE_HELP")
public void create(@Guard Player p, String name) {
if (SimulatorStorage.getSimulatorNames().contains(name)) {
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", p);
return;
}
SimulatorStorage.createNewSimulator(name);
BauSystem.MESSAGE.send("SIMULATOR_CREATE", p);
}
@ClassGuard(value = Player.class, local = true) @ClassGuard(value = Player.class, local = true)
public GuardChecker guardChecker() { public GuardChecker guardChecker() {
return (commandSender, guardCheckType, strings, s) -> { return (commandSender, guardCheckType, strings, s) -> {

Datei anzeigen

@ -73,11 +73,13 @@ public class SimulatorCursor {
if (cursor != null) if (cursor != null)
cursor.hide(player, false); cursor.hide(player, false);
tntSimulator.hide(player); if (tntSimulator != null) {
tntSimulator.remove(player);
}
cursors.remove(player); cursors.remove(player);
} }
private Vector getPos(Player player, RayTraceResult result) { public static Vector getPos(Player player, RayTraceResult result) {
Vector pos = result.getHitPosition(); Vector pos = result.getHitPosition();
BlockFace face = result.getHitBlockFace(); BlockFace face = result.getHitBlockFace();

Datei anzeigen

@ -59,6 +59,10 @@ public class SimulatorStorage implements Enable, Disable {
private static Map<String, TNTSimulator> tntSimulators = new HashMap<>(); private static Map<String, TNTSimulator> tntSimulators = new HashMap<>();
public static void createNewSimulator(String name) {
tntSimulators.put(name, new TNTSimulator());
}
public static Set<String> getSimulatorNames() { public static Set<String> getSimulatorNames() {
return tntSimulators.keySet(); return tntSimulators.keySet();
} }

Datei anzeigen

@ -27,15 +27,13 @@ import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.RayTraceResult;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import yapion.hierarchy.types.YAPIONArray; import yapion.hierarchy.types.YAPIONArray;
import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONObject;
import yapion.hierarchy.types.YAPIONType; import yapion.hierarchy.types.YAPIONType;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Getter @Getter
@ -84,6 +82,16 @@ public class TNTSimulator {
}); });
} }
public void remove(Player player) {
SimulatorEntityShowMode showMode = playerShowMode.remove(player);
if (showMode == null) {
return;
}
tntElementList.forEach(simulatorElement -> {
simulatorElement.hide(showMode);
});
}
public void hide(Player player, List<SimulatorElement> simulatorElements) { public void hide(Player player, List<SimulatorElement> simulatorElements) {
SimulatorEntityShowMode showMode = playerShowMode.get(player); SimulatorEntityShowMode showMode = playerShowMode.get(player);
if (showMode == null) { if (showMode == null) {
@ -108,8 +116,41 @@ public class TNTSimulator {
public List<SimulatorElement> getEntity(Entity entity) { public List<SimulatorElement> getEntity(Entity entity) {
List<SimulatorElement> tntSpawns = new ArrayList<>(); List<SimulatorElement> tntSpawns = new ArrayList<>();
for (SimulatorElement spawn : tntElementList) { for (SimulatorElement spawn : tntElementList) {
spawn.getEntity(tntSpawns, new Vector(0, 0, 0), entity); spawn.getEntity(tntSpawns, entity);
} }
return tntSpawns; return tntSpawns;
} }
public void edit(Player player, RayTraceResult result) {
if (result == null) {
// TODO: Open gui
return;
}
SimulatorCursor.show(player, this, result);
if (result.getHitEntity() != null) {
return;
}
/*
if (result.getHitEntity() != null) {
List<de.steamwar.bausystem.features.simulator.TNTSimulator.TNTSpawn> tntSpawns = getEntity(result.getHitEntity());
if (tntSpawns.isEmpty()) {
return;
}
if (tntSpawns.size() == 1) {
tntSpawns.get(0).editTNT(spawns);
} else {
showGUI(new HashSet<>(tntSpawns));
}
return;
}
*/
tntElementList.add(new TNTElement(SimulatorCursor.getPos(player, result)));
playerShowMode.forEach((p, simulatorEntityShowMode) -> {
show(p);
});
}
} }

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.bausystem.utils.ItemUtils;
import org.bukkit.FluidCollisionMode; import org.bukkit.FluidCollisionMode;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -54,6 +55,10 @@ public class TNTSimulatorListener implements Listener {
} }
static RayTraceResult trace(Player player, Location to, TNTSimulator simulator) { static RayTraceResult trace(Player player, Location to, TNTSimulator simulator) {
if (player.getGameMode() == GameMode.SPECTATOR) {
return null;
}
Location startPos = to.clone().add(0.0, player.getEyeHeight(), 0.0); Location startPos = to.clone().add(0.0, player.getEyeHeight(), 0.0);
Vector direction = to.getDirection(); Vector direction = to.getDirection();
RayTraceResult blocks = player.getWorld().rayTraceBlocks(startPos, direction, 10.0, FluidCollisionMode.NEVER, true); RayTraceResult blocks = player.getWorld().rayTraceBlocks(startPos, direction, 10.0, FluidCollisionMode.NEVER, true);
@ -89,7 +94,7 @@ public class TNTSimulatorListener implements Listener {
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent e) { public void onPlayerMove(PlayerMoveEvent e) {
simulatorShowHide(e.getPlayer(), ignore -> null, PlayerInventory::getItemInMainHand, e.getTo()); simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo());
} }
@EventHandler @EventHandler
@ -99,9 +104,7 @@ public class TNTSimulatorListener implements Listener {
private void simulatorShowHide(Player player, Function<PlayerInventory, ItemStack> oldItemFunction, Function<PlayerInventory, ItemStack> newItemFunction, Location location) { private void simulatorShowHide(Player player, Function<PlayerInventory, ItemStack> oldItemFunction, Function<PlayerInventory, ItemStack> newItemFunction, Location location) {
TNTSimulator oldSimulator = SimulatorStorage.getSimulator(oldItemFunction.apply(player.getInventory())); TNTSimulator oldSimulator = SimulatorStorage.getSimulator(oldItemFunction.apply(player.getInventory()));
if (oldSimulator != null) {
SimulatorCursor.hide(player, oldSimulator); SimulatorCursor.hide(player, oldSimulator);
}
TNTSimulator simulator = SimulatorStorage.getSimulator(newItemFunction.apply(player.getInventory())); TNTSimulator simulator = SimulatorStorage.getSimulator(newItemFunction.apply(player.getInventory()));
if (simulator == null) { if (simulator == null) {
@ -136,9 +139,8 @@ public class TNTSimulatorListener implements Listener {
if (simulator == null) { if (simulator == null) {
SimulatorSelectionGUI.open(event.getPlayer(), event.getItem()); SimulatorSelectionGUI.open(event.getPlayer(), event.getItem());
} else { } else {
simulator.edit(event.getPlayer(), trace(event.getPlayer(), event.getPlayer().getLocation(), simulator));
} }
// get(event.getPlayer()).edit(trace(event.getPlayer(), event.getPlayer().getLocation()));
break; break;
default: default:
break; break;

Datei anzeigen

@ -43,9 +43,14 @@ public class SimulatorSelectionGUI {
swListEntryList.add(new SWListInv.SWListEntry<>(swItem, simulator)); swListEntryList.add(new SWListInv.SWListEntry<>(swItem, simulator));
} }
SWListInv<TNTSimulator> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATORN_GUI_SELECT_SIM", player), false, swListEntryList, (clickType, tntSimulator) -> { SWListInv<TNTSimulator> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_SELECT_SIM", player), false, swListEntryList, (clickType, tntSimulator) -> {
TNTSimulator current = SimulatorStorage.getSimulator(hand);
if (current != null) {
current.remove(player);
}
SimulatorStorage.setSimulator(hand, tntSimulator); SimulatorStorage.setSimulator(hand, tntSimulator);
player.getInventory().setItemInMainHand(hand); player.getInventory().setItemInMainHand(hand);
player.closeInventory();
}); });
// TODO: Add button to create new simulator with AnvilGUI // TODO: Add button to create new simulator with AnvilGUI

Datei anzeigen

@ -25,8 +25,6 @@ import de.steamwar.bausystem.shared.Position;
import de.steamwar.bausystem.shared.RoundedPosition; import de.steamwar.bausystem.shared.RoundedPosition;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.bausystem.utils.NMSWrapper;
import org.bukkit.World;
import org.bukkit.entity.Panda;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;

Datei anzeigen

@ -33,7 +33,7 @@ public interface SimulatorElement {
YAPIONObject toYAPION(); YAPIONObject toYAPION();
List<Entity> getEntities(); List<Entity> getEntities();
void getEntity(List<SimulatorElement> elements, Vector origin, Entity entity); void getEntity(List<SimulatorElement> elements, Entity entity);
default Vector getPosition() { default Vector getPosition() {
return new Vector(0, 0, 0); return new Vector(0, 0, 0);
} }
@ -42,5 +42,5 @@ public interface SimulatorElement {
void hide(SimulatorEntityShowMode showMode); void hide(SimulatorEntityShowMode showMode);
ItemStack menu(); ItemStack menu();
void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result, Vector origin, int tickOffset); // Ticks to subtick order to spawning runnable to count of activations void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result); // Ticks to subtick order to spawning runnable to count of activations
} }

Datei anzeigen

@ -24,9 +24,9 @@ import de.steamwar.bausystem.features.simulatorn.SimulatorStorage;
import de.steamwar.bausystem.features.simulatorn.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulatorn.show.SimulatorEntityShowMode;
import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.shared.Position; import de.steamwar.bausystem.shared.Position;
import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -37,9 +37,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@Getter
public class TNTElement implements SimulatorElement { public class TNTElement implements SimulatorElement {
private final AbstractSimulatorEntity entity; private final AbstractSimulatorEntity entity;
TNTGroup tntGroup = null;
private final Vector position; private final Vector position;
private int fuseTicks = 80; private int fuseTicks = 80;
@ -92,25 +94,35 @@ public class TNTElement implements SimulatorElement {
} }
@Override @Override
public void getEntity(List<SimulatorElement> elements, Vector origin, Entity entity) { public void getEntity(List<SimulatorElement> elements, Entity entity) {
if (this.entity.getId() == entity.getEntityId() || position.clone().add(origin).equals(entity.getLocation().toVector())) { if (this.entity.getId() == entity.getEntityId() || getPosition().equals(entity.getLocation().toVector())) {
elements.add(this); elements.add(this);
} }
} }
@Override @Override
public Vector getPosition() { public Vector getPosition() {
if (tntGroup != null) {
return tntGroup.getPosition().clone().add(position);
}
return position.clone(); return position.clone();
} }
protected int getTickOffset() {
if (tntGroup != null) {
return tntGroup.getTickOffset() + tickOffset;
}
return tickOffset;
}
@Override @Override
public void show(SimulatorEntityShowMode showMode) { public void show(SimulatorEntityShowMode showMode) {
showMode.show(new Position(position)); showMode.show(new Position(getPosition()));
} }
@Override @Override
public void hide(SimulatorEntityShowMode showMode) { public void hide(SimulatorEntityShowMode showMode) {
showMode.hide(); showMode.hide(new Position(getPosition()));
} }
@Override @Override
@ -119,10 +131,10 @@ public class TNTElement implements SimulatorElement {
} }
@Override @Override
public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result, Vector origin, int tickOffset) { public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result) {
result.computeIfAbsent(this.tickOffset + tickOffset, ignore -> new HashMap<>()) result.computeIfAbsent(getTickOffset(), ignore -> new HashMap<>())
.computeIfAbsent(order, ignore -> new Pair<>(() -> { .computeIfAbsent(order, ignore -> new Pair<>(() -> {
SimulatorStorage.WORLD.spawn(position.clone().add(origin).toLocation(SimulatorStorage.WORLD), TNTPrimed.class, tntPrimed -> { SimulatorStorage.WORLD.spawn(getPosition().toLocation(SimulatorStorage.WORLD), TNTPrimed.class, tntPrimed -> {
tntPrimed.setFuseTicks(fuseTicks); tntPrimed.setFuseTicks(fuseTicks);
if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0)); if (!xVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0));
if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0)); if (!yVelocity) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0));

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.simulatorn.tnt;
import de.steamwar.bausystem.features.simulatorn.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulatorn.show.SimulatorEntityShowMode;
import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Pair;
import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -33,6 +34,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Getter
public class TNTGroup implements SimulatorElement { public class TNTGroup implements SimulatorElement {
private final Vector position; private final Vector position;
@ -50,7 +52,9 @@ public class TNTGroup implements SimulatorElement {
this.material = Material.getMaterial(yapionObject.getStringOrDefault("material", "BARREL")); this.material = Material.getMaterial(yapionObject.getStringOrDefault("material", "BARREL"));
YAPIONArray elements = yapionObject.getArrayOrDefault("elements", new YAPIONArray()); YAPIONArray elements = yapionObject.getArrayOrDefault("elements", new YAPIONArray());
for (YAPIONObject element : elements.streamObject().collect(Collectors.toList())) { for (YAPIONObject element : elements.streamObject().collect(Collectors.toList())) {
this.elements.add(new TNTElement(element)); TNTElement tntElement = new TNTElement(element);
tntElement.tntGroup = this;
this.elements.add(tntElement);
} }
} }
@ -76,9 +80,9 @@ public class TNTGroup implements SimulatorElement {
} }
@Override @Override
public void getEntity(List<SimulatorElement> elements, Vector origin, Entity entity) { public void getEntity(List<SimulatorElement> elements, Entity entity) {
for (TNTElement tntElement : this.elements) { for (TNTElement tntElement : this.elements) {
tntElement.getEntity(elements, origin, entity); tntElement.getEntity(elements, entity);
} }
} }
@ -102,9 +106,9 @@ public class TNTGroup implements SimulatorElement {
} }
@Override @Override
public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result, Vector origin, int tickOffset) { public void locations(Map<Integer, Map<Integer, Pair<Runnable, Integer>>> result) {
elements.forEach(tntElement -> { elements.forEach(tntElement -> {
tntElement.locations(result, origin.clone().add(position), this.tickOffset + tickOffset); tntElement.locations(result);
}); });
} }
} }