Fixed #227 and made subpixelalignment more user friendly
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
719b38f5af
Commit
c369662a28
@ -26,12 +26,17 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorTNTGui;
|
||||
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
|
||||
import de.steamwar.inventory.InvCallback;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
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) {
|
||||
super(Material.TNT, position);
|
||||
}
|
||||
@ -47,26 +52,16 @@ public final class TNTElement extends SimulatorElement<TNTPhase> {
|
||||
position.setZ(position.getZ() + z);
|
||||
}
|
||||
|
||||
public void align(Vector offset) {
|
||||
if (offset.getX() != 0) {
|
||||
if (position.getX() - (int) position.getX() == 0.49) {
|
||||
position.setX(position.getX() + 0.02);
|
||||
}
|
||||
if (position.getX() - (int) position.getX() == -0.49) {
|
||||
position.setX(position.getX() - 0.02);
|
||||
}
|
||||
position.setX(position.getBlockX() + offset.getX());
|
||||
}
|
||||
public void alignX(int direction) {
|
||||
position.setX(position.getX() - SUB_PIXEL * alignment.getX());
|
||||
alignment.setX(direction);
|
||||
position.setX(position.getX() + SUB_PIXEL * alignment.getX());
|
||||
}
|
||||
|
||||
if (offset.getZ() != 0) {
|
||||
if (position.getZ() - (int) position.getZ() == 0.49) {
|
||||
position.setZ(position.getZ() + 0.02);
|
||||
}
|
||||
if (position.getZ() - (int) position.getZ() == -0.49) {
|
||||
position.setZ(position.getZ() - 0.02);
|
||||
}
|
||||
position.setZ(position.getBlockZ() + offset.getZ());
|
||||
}
|
||||
public void alignZ(int direction) {
|
||||
position.setZ(position.getZ() - SUB_PIXEL * alignment.getZ());
|
||||
alignment.setZ(direction);
|
||||
position.setZ(position.getZ() + SUB_PIXEL * alignment.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,41 +97,69 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
||||
if (allTNT) {
|
||||
// Subpixel Alignment
|
||||
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||
tnt.align(new Vector(0.5, 0, 0.5));
|
||||
});
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
tntElement.alignX(0);
|
||||
tntElement.alignZ(0);
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
|
||||
// Z
|
||||
inventory.setItem(20, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||
tnt.align(new Vector(0, 0, 0.49));
|
||||
});
|
||||
SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getZ() != -1) tntElement.alignZ(-1);
|
||||
});
|
||||
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 -> {
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||
tnt.align(new Vector(0, 0, 0.51));
|
||||
});
|
||||
SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
if (tntElement.getAlignment().getZ() != 1) tntElement.alignZ(1);
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
});
|
||||
positivZItem.setEnchanted(simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.allMatch(tntElement -> tntElement.getAlignment().getZ() == 1));
|
||||
inventory.setItem(22, positivZItem);
|
||||
|
||||
// X
|
||||
inventory.setItem(12, new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
||||
tnt.align(new Vector(0.49, 0, 0));
|
||||
});
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||
simulatorGroup.getElements().stream()
|
||||
.map(TNTElement.class::cast)
|
||||
.forEach(tntElement -> {
|
||||
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);
|
||||
}));
|
||||
});
|
||||
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
|
||||
|
@ -99,31 +99,40 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
|
||||
|
||||
// Subpixel Alignment
|
||||
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);
|
||||
}));
|
||||
|
||||
// Z
|
||||
inventory.setItem(20, new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||
tnt.align(new Vector(0, 0, 0.49));
|
||||
SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
|
||||
if (tnt.getAlignment().getZ() != -1) tnt.alignZ(-1);
|
||||
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 -> {
|
||||
tnt.align(new Vector(0, 0, 0.51));
|
||||
SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
|
||||
if (tnt.getAlignment().getZ() != 1) tnt.alignZ(1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
});
|
||||
positivZItem.setEnchanted(tnt.getAlignment().getZ() == 1);
|
||||
inventory.setItem(22, positivZItem);
|
||||
|
||||
// X
|
||||
inventory.setItem(12, new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||
tnt.align(new Vector(0.49, 0, 0));
|
||||
SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
|
||||
if (tnt.getAlignment().getX() != -1) tnt.alignX(-1);
|
||||
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 -> {
|
||||
tnt.align(new Vector(0.51, 0, 0));
|
||||
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
||||
if(tnt.getAlignment().getX() != 1) tnt.alignX(1);
|
||||
SimulatorWatcher.update(simulator);
|
||||
}));
|
||||
});
|
||||
positivXItem.setEnchanted(tnt.getAlignment().getX() == 1);
|
||||
inventory.setItem(30, positivXItem);
|
||||
|
||||
// Pos X
|
||||
inventory.setItem(15, SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren