SteamWar/BauSystem2.0
Archiviert
12
0

Add alignment buttons
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-06-11 15:48:37 +02:00
Ursprung 576e39ac0b
Commit a0476da4d8
3 geänderte Dateien mit 71 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -558,6 +558,12 @@ SIMULATOR_GUI_START = §eStart
SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0}
SIMULATOR_GUI_MOVE_ALL = §eMove all
SIMULATOR_ALIGNMENT_CENTER = §7Alignment§8: §eCenter
SIMULATOR_ALIGNMENT_POSITIVE_X = §7Alignment§8: §ePositive X
SIMULATOR_ALIGNMENT_NEGATIVE_X = §7Alignment§8: §eNegative X
SIMULATOR_ALIGNMENT_POSITIVE_Z = §7Alignment§8: §ePositive Z
SIMULATOR_ALIGNMENT_NEGATIVE_Z = §7Alignment§8: §eNegative Z
SIMULATOR_MOVE_ALL_GUI_NAME = Move TNT
SIMULATOR_TNT_SPAWN_GUI_NAME = Configure TNT {0}

Datei anzeigen

@ -556,6 +556,12 @@ SIMULATOR_GUI_START = §eStarten
SIMULATOR_GUI_AUTO_TRACE = §eAutoTrace§8: §7{0}
SIMULATOR_GUI_MOVE_ALL = §eAlle Verschieben
SIMULATOR_ALIGNMENT_CENTER = §7Verschiebung§8: §eMitte
SIMULATOR_ALIGNMENT_POSITIVE_X = §7Verschiebung§8: §ePositive X
SIMULATOR_ALIGNMENT_NEGATIVE_X = §7Verschiebung§8: §eNegative X
SIMULATOR_ALIGNMENT_POSITIVE_Z = §7Verschiebung§8: §ePositive Z
SIMULATOR_ALIGNMENT_NEGATIVE_Z = §7Verschiebung§8: §eNegative Z
SIMULATOR_MOVE_ALL_GUI_NAME = TNT Verschieben
SIMULATOR_TNT_SPAWN_GUI_NAME = TNT konfigurieren {0}

Datei anzeigen

@ -116,22 +116,53 @@ public class TNTElementGUI {
inv.setItem(36, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SIMULATOR_BACK", player), clickType -> back.run()));
}
String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player);
String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player);
List<String> plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player));
List<String> minusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_MINUS_PIXEL_SHIFT", player));
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player));
Runnable editObserver = () -> {
TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player.getInventory().getItemInMainHand());
ChangePosition.show(inv, player, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back));
// Alignment
/*
inv.setItem(24, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("", player), clickType -> {
inv.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative
if (tntSimulator != null) tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition();
align(position, new Vector(0, 0, 0.49));
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
if (tntSimulator != null) tntSimulator.show(tntElement);
tntElement.change();
}));
inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive
if (tntSimulator != null) tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition();
align(position, new Vector(0, 0, 0.51));
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
if (tntSimulator != null) tntSimulator.show(tntElement);
tntElement.change();
}));
inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive
if (tntSimulator != null) tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition();
align(position, new Vector(0.51, 0, 0));
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
if (tntSimulator != null) tntSimulator.show(tntElement);
tntElement.change();
}));
inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative
if (tntSimulator != null) tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition();
align(position, new Vector(0.49, 0, 0));
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
if (tntSimulator != null) tntSimulator.show(tntElement);
tntElement.change();
}));
inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER
if (tntSimulator != null) tntSimulator.hide(tntElement);
Vector position = tntElement.getPosition();
align(position, new Vector(0.5, 0, 0.5));
tntElement.getOwnPosition().setX(position.getX() - tntElement.getParentPosition().getX());
tntElement.getOwnPosition().setZ(position.getZ() - tntElement.getParentPosition().getZ());
if (tntSimulator != null) tntSimulator.show(tntElement);
tntElement.change();
}));
*/
};
editObserver.run();
tntElement.register(editObserver, player::closeInventory);
@ -140,6 +171,25 @@ 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) {