@ -26,12 +26,18 @@ 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;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
public final class TNTElement extends SimulatorElement<TNTPhase> {
|
public final class TNTElement extends SimulatorElement<TNTPhase> {
|
||||||
|
|
||||||
|
public static final double SUB_PIXEL = 0.00999999046326;
|
||||||
|
@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 +53,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
|
||||||
@ -102,4 +98,16 @@ public final class TNTElement extends SimulatorElement<TNTPhase> {
|
|||||||
public String getType() {
|
public String getType() {
|
||||||
return "TNT";
|
return "TNT";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveExtra(YAPIONObject elementObject) {
|
||||||
|
elementObject.add("alignmentX", alignment.getX());
|
||||||
|
elementObject.add("alignmentZ", alignment.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadExtra(YAPIONObject elementObject) {
|
||||||
|
alignment.setX(elementObject.getDoubleOrSetDefault("alignmentX", 0));
|
||||||
|
alignment.setZ(elementObject.getDoubleOrSetDefault("alignmentZ", 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 -> {
|
||||||
|
if (tntElement.getAlignment().getX() != -1) tntElement.alignX(-1);
|
||||||
});
|
});
|
||||||
SimulatorWatcher.update(simulator);
|
|
||||||
}));
|
|
||||||
|
|
||||||
inventory.setItem(30, new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
|
SimulatorWatcher.update(simulator);
|
||||||
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tnt -> {
|
});
|
||||||
tnt.align(new Vector(0.51, 0, 0));
|
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);
|
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
|
||||||
@ -140,6 +168,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
|
||||||
|
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
|
||||||
|
if(!allTNT){
|
||||||
|
number = (double) Math.round(number);
|
||||||
|
}
|
||||||
|
simulatorGroup.move(number, 0, 0);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
return true;
|
||||||
|
}, this).setItem(Material.PAPER).open();
|
||||||
}));
|
}));
|
||||||
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(33, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
|
||||||
@ -152,6 +188,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
|
||||||
|
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
|
||||||
|
if(!allTNT){
|
||||||
|
number = (double) Math.round(number);
|
||||||
|
}
|
||||||
|
simulatorGroup.move(0, number, 0);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
return true;
|
||||||
|
}, this).setItem(Material.PAPER).open();
|
||||||
}));
|
}));
|
||||||
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(34, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
|
||||||
@ -164,6 +208,14 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
|
|||||||
SimulatorWatcher.update(simulator);
|
SimulatorWatcher.update(simulator);
|
||||||
});
|
});
|
||||||
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
|
||||||
|
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
|
||||||
|
if(!allTNT){
|
||||||
|
number = (double) Math.round(number);
|
||||||
|
}
|
||||||
|
simulatorGroup.move(0, 0, number);
|
||||||
|
SimulatorWatcher.update(simulator);
|
||||||
|
return true;
|
||||||
|
}, this).setItem(Material.PAPER).open();
|
||||||
}));
|
}));
|
||||||
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
inventory.setItem(35, SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
|
||||||
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
|
||||||
|
@ -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 -> {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren