SteamWar/BauSystem2.0
Archiviert
12
0

Fixed #227 and made subpixelalignment more user friendly
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
D4rkr34lm 2024-04-02 22:35:27 +02:00
Ursprung 719b38f5af
Commit c369662a28
3 geänderte Dateien mit 88 neuen und 56 gelöschten Zeilen

Datei anzeigen

@ -26,12 +26,17 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorTNTGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui; import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.inventory.InvCallback; import de.steamwar.inventory.InvCallback;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import lombok.Getter;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public final class TNTElement extends SimulatorElement<TNTPhase> { public final class TNTElement extends SimulatorElement<TNTPhase> {
public static final double SUB_PIXEL = 0.0999999046326;
@Getter
private final Vector alignment = new Vector();
public TNTElement(Vector position) { public TNTElement(Vector position) {
super(Material.TNT, position); super(Material.TNT, position);
} }
@ -47,26 +52,16 @@ public final class TNTElement extends SimulatorElement<TNTPhase> {
position.setZ(position.getZ() + z); position.setZ(position.getZ() + z);
} }
public void align(Vector offset) { public void alignX(int direction) {
if (offset.getX() != 0) { position.setX(position.getX() - SUB_PIXEL * alignment.getX());
if (position.getX() - (int) position.getX() == 0.49) { alignment.setX(direction);
position.setX(position.getX() + 0.02); position.setX(position.getX() + SUB_PIXEL * alignment.getX());
} }
if (position.getX() - (int) position.getX() == -0.49) {
position.setX(position.getX() - 0.02);
}
position.setX(position.getBlockX() + offset.getX());
}
if (offset.getZ() != 0) { public void alignZ(int direction) {
if (position.getZ() - (int) position.getZ() == 0.49) { position.setZ(position.getZ() - SUB_PIXEL * alignment.getZ());
position.setZ(position.getZ() + 0.02); alignment.setZ(direction);
} position.setZ(position.getZ() + SUB_PIXEL * alignment.getZ());
if (position.getZ() - (int) position.getZ() == -0.49) {
position.setZ(position.getZ() - 0.02);
}
position.setZ(position.getBlockZ() + offset.getZ());
}
} }
@Override @Override

Datei anzeigen

@ -97,41 +97,69 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
if (allTNT) { if (allTNT) {
// Subpixel Alignment // Subpixel Alignment
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> { inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> { simulatorGroup.getElements().stream()
tnt.align(new Vector(0.5, 0, 0.5)); .map(TNTElement.class::cast)
}); .forEach(tntElement -> {
tntElement.alignX(0);
tntElement.alignZ(0);
});
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); }));
// Z // Z
inventory.setItem(20, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> { SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> { simulatorGroup.getElements().stream()
tnt.align(new Vector(0, 0, 0.49)); .map(TNTElement.class::cast)
}); .forEach(tntElement -> {
if (tntElement.getAlignment().getZ() != -1) tntElement.alignZ(-1);
});
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
negativZItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getZ() == -1));
inventory.setItem(20, negativZItem);
inventory.setItem(22, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> { SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> { simulatorGroup.getElements().stream()
tnt.align(new Vector(0, 0, 0.51)); .map(TNTElement.class::cast)
}); .forEach(tntElement -> {
if (tntElement.getAlignment().getZ() != 1) tntElement.alignZ(1);
});
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
positivZItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getZ() == 1));
inventory.setItem(22, positivZItem);
// X // X
inventory.setItem(12, new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> { SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> { simulatorGroup.getElements().stream()
tnt.align(new Vector(0.49, 0, 0)); .map(TNTElement.class::cast)
}); .forEach(tntElement -> {
SimulatorWatcher.update(simulator); if (tntElement.getAlignment().getX() != -1) tntElement.alignX(-1);
})); });
inventory.setItem(30, new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
tnt.align(new Vector(0.51, 0, 0));
});
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
negativXItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
inventory.setItem(12, negativXItem);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
if (tntElement.getAlignment().getX() != 1) tntElement.alignX(1);
});
SimulatorWatcher.update(simulator);
});
positivXItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
inventory.setItem(30, positivXItem);
} }
//Pos X //Pos X

Datei anzeigen

@ -99,31 +99,40 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
// Subpixel Alignment // Subpixel Alignment
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> { inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
tnt.align(new Vector(0.5, 0, 0.5)); tnt.alignX(0);
tnt.alignZ(0);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); }));
// Z // Z
inventory.setItem(20, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> { SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
tnt.align(new Vector(0, 0, 0.49)); if (tnt.getAlignment().getZ() != -1) tnt.alignZ(-1);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
negativZItem.setEnchanted(tnt.getAlignment().getZ() == -1);
inventory.setItem(20, negativZItem);
inventory.setItem(22, new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> { SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
tnt.align(new Vector(0, 0, 0.51)); if (tnt.getAlignment().getZ() != 1) tnt.alignZ(1);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
positivZItem.setEnchanted(tnt.getAlignment().getZ() == 1);
inventory.setItem(22, positivZItem);
// X // X
inventory.setItem(12, new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> { SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
tnt.align(new Vector(0.49, 0, 0)); if (tnt.getAlignment().getX() != -1) tnt.alignX(-1);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
negativXItem.setEnchanted(tnt.getAlignment().getX() == -1);
inventory.setItem(12, negativXItem);
inventory.setItem(30, new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> { SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
tnt.align(new Vector(0.51, 0, 0)); if(tnt.getAlignment().getX() != 1) tnt.alignX(1);
SimulatorWatcher.update(simulator); SimulatorWatcher.update(simulator);
})); });
positivXItem.setEnchanted(tnt.getAlignment().getX() == 1);
inventory.setItem(30, positivXItem);
// Pos X // Pos X
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> { inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {