SteamWar/BauSystem2.0
Archiviert
12
0

Fix alignment the second time
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-02-25 15:12:49 +01:00
Ursprung 1086808cf0
Commit 5d1fb567ef
2 geänderte Dateien mit 32 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -136,37 +136,27 @@ public class TNTElementGUI {
// Alignment
inv.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
if (clickType == ClickType.DOUBLE_CLICK) return;
Vector position = tntElement.getOwnPosition();
align(position, new Vector(0.5, 0, 0.49));
tntElement.setPosition(position);
tntElement.align(new Vector(0.5, 0, 0.49));
tntElement.change();
}));
inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
if (clickType == ClickType.DOUBLE_CLICK) return;
Vector position = tntElement.getOwnPosition();
align(position, new Vector(0.5, 0, 0.51));
tntElement.setPosition(position);
tntElement.align(new Vector(0.5, 0, 0.51));
tntElement.change();
}));
inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
if (clickType == ClickType.DOUBLE_CLICK) return;
Vector position = tntElement.getOwnPosition();
align(position, new Vector(0.51, 0, 0.5));
tntElement.setPosition(position);
tntElement.align(new Vector(0.51, 0, 0.5));
tntElement.change();
}));
inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
if (clickType == ClickType.DOUBLE_CLICK) return;
Vector position = tntElement.getOwnPosition();
align(position, new Vector(0.49, 0, 0.5));
tntElement.setPosition(position);
tntElement.align(new Vector(0.49, 0, 0.5));
tntElement.change();
}));
inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
if (clickType == ClickType.DOUBLE_CLICK) return;
Vector position = tntElement.getOwnPosition();
align(position, new Vector(0.5, 0, 0.5));
tntElement.setPosition(position);
tntElement.align(new Vector(0.5, 0, 0.5));
tntElement.change();
}));
};
@ -179,25 +169,6 @@ public class TNTElementGUI {
inv.open();
}
private void align(Vector vector, Vector offset) {
if (vector.getX() - (int) vector.getX() == 0.49) {
vector.setX(vector.getX() + 0.02);
}
if (vector.getX() - (int) vector.getX() == -0.49) {
vector.setX(vector.getX() - 0.02);
}
if (vector.getZ() - (int) vector.getZ() == 0.49) {
vector.setZ(vector.getZ() + 0.02);
}
if (vector.getZ() - (int) vector.getZ() == -0.49) {
vector.setZ(vector.getZ() - 0.02);
}
vector.setX(vector.getBlockX() + offset.getX());
vector.setY(vector.getBlockY() + offset.getY());
vector.setZ(vector.getBlockZ() + offset.getZ());
}
private void editProperties(Player player, TNTElement tntElement, Runnable back) {
SWInventory inv = open(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_EDIT_PROPERTIES", player));
if (back != null) {

Datei anzeigen

@ -285,4 +285,31 @@ public class TNTElement implements SimulatorElement {
this.disabled = disabled;
_updatePosition();
}
public void align(Vector offset) {
Vector vector = getPosition();
Vector parentVector = new Vector(0, 0, 0);
if (tntGroup != null) {
parentVector = tntGroup.getPosition();
}
if (vector.getX() - (int) vector.getX() == 0.49) {
vector.setX(vector.getX() + 0.02);
}
if (vector.getX() - (int) vector.getX() == -0.49) {
vector.setX(vector.getX() - 0.02);
}
if (vector.getZ() - (int) vector.getZ() == 0.49) {
vector.setZ(vector.getZ() + 0.02);
}
if (vector.getZ() - (int) vector.getZ() == -0.49) {
vector.setZ(vector.getZ() - 0.02);
}
vector.setX(vector.getBlockX() + offset.getX());
vector.setY(vector.getBlockY() + offset.getY());
vector.setZ(vector.getBlockZ() + offset.getZ());
setPosition(vector.subtract(parentVector));
}
}