Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
bc646cdce7
@ -31,7 +31,7 @@ class SimulatorEntity_15 extends BaseEntity_15 implements AbstractSimulatorEntit
|
|||||||
private ReferenceCounter referenceCounter = new ReferenceCounter();
|
private ReferenceCounter referenceCounter = new ReferenceCounter();
|
||||||
|
|
||||||
public SimulatorEntity_15(World world, Vector position, boolean highlight) {
|
public SimulatorEntity_15(World world, Vector position, boolean highlight) {
|
||||||
super(world, position, highlight ? Material.TNT : Material.WHITE_STAINED_GLASS);
|
super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT);
|
||||||
|
|
||||||
this.setNoGravity(true);
|
this.setNoGravity(true);
|
||||||
this.ticksLived = -12000;
|
this.ticksLived = -12000;
|
||||||
|
@ -29,8 +29,6 @@ import de.steamwar.inventory.SWAnvilInv;
|
|||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -49,6 +47,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class TNTSimulator {
|
public class TNTSimulator {
|
||||||
|
|
||||||
|
private static final Vector X_VECTOR = new Vector(0.0625, 0, 0);
|
||||||
|
private static final Vector Y_VECTOR = new Vector(0, 0.0625, 0);
|
||||||
|
private static final Vector Z_VECTOR = new Vector(0, 0, 0.0625);
|
||||||
|
|
||||||
private static final World WORLD = Bukkit.getWorlds().get(0);
|
private static final World WORLD = Bukkit.getWorlds().get(0);
|
||||||
private static final List<String> LORE = Collections.singletonList("§eZum Ändern klicken");
|
private static final List<String> LORE = Collections.singletonList("§eZum Ändern klicken");
|
||||||
private static final List<TNTSpawn> EMPTY = new ArrayList<>();
|
private static final List<TNTSpawn> EMPTY = new ArrayList<>();
|
||||||
@ -71,63 +73,70 @@ public class TNTSimulator {
|
|||||||
private AbstractSimulatorEntity cursor = null;
|
private AbstractSimulatorEntity cursor = null;
|
||||||
private boolean printed = false;
|
private boolean printed = false;
|
||||||
|
|
||||||
private TNTSimulator(Player player){
|
private TNTSimulator(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Entity> getEntities(){
|
public List<Entity> getEntities() {
|
||||||
return spawns.stream().map(spawn -> spawn.entity.getBukkitEntity()).collect(Collectors.toList());
|
return spawns.stream().map(spawn -> spawn.entity.getBukkitEntity()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(RayTraceResult result){
|
public void show(RayTraceResult result) {
|
||||||
printed = true;
|
printed = true;
|
||||||
|
|
||||||
if(cursor != null)
|
if (cursor != null)
|
||||||
cursor.hide(player, false);
|
cursor.hide(player, false);
|
||||||
|
|
||||||
spawns.forEach(TNTSpawn::show);
|
spawns.forEach(TNTSpawn::show);
|
||||||
|
|
||||||
if(result == null)
|
if (result == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(result.getHitEntity() != null){
|
if (result.getHitEntity() != null) {
|
||||||
TNTSpawn entity = getEntity(result.getHitEntity());
|
List<TNTSpawn> tntSpawns = getEntity(result.getHitEntity());
|
||||||
entity.hide();
|
tntSpawns.forEach(TNTSpawn::hide);
|
||||||
|
|
||||||
cursor = SimulatorEntityShowMode.createEntity(player, entity.position, false);
|
cursor = SimulatorEntityShowMode.createEntity(player, tntSpawns.isEmpty() ? getPos(result) : tntSpawns.get(0).position, true);
|
||||||
cursor.display(player);
|
cursor.display(player);
|
||||||
SWUtils.sendToActionbar(player, ColorConfig.HIGHLIGHT + "Position bearbeiten");
|
SWUtils.sendToActionbar(player, ColorConfig.HIGHLIGHT + "Position bearbeiten");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = SimulatorEntityShowMode.createEntity(player, getPos(result), true);
|
cursor = SimulatorEntityShowMode.createEntity(player, getPos(result), false);
|
||||||
cursor.display(player);
|
cursor.display(player);
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§ePosition setzen"));
|
SWUtils.sendToActionbar(player, ColorConfig.HIGHLIGHT + "Position setzen");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void edit(RayTraceResult result){
|
public void edit(RayTraceResult result) {
|
||||||
if(result == null) {
|
if (result == null) {
|
||||||
showGUI();
|
showGUI();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
show(result);
|
show(result);
|
||||||
|
|
||||||
if(result.getHitEntity() != null){
|
if (result.getHitEntity() != null) {
|
||||||
TNTSpawn entity = getEntity(result.getHitEntity());
|
List<TNTSpawn> tntSpawns = getEntity(result.getHitEntity());
|
||||||
entity.editTNT();
|
if (tntSpawns.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tntSpawns.size() == 1) {
|
||||||
|
tntSpawns.get(0).editTNT();
|
||||||
|
} else {
|
||||||
|
showGUI(new HashSet<>(tntSpawns));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spawns.add(new TNTSpawn(getPos(result), cursor));
|
spawns.add(new TNTSpawn(getPos(result), cursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hide(){
|
public void hide() {
|
||||||
if(!printed)
|
if (!printed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printed = false;
|
printed = false;
|
||||||
if(cursor != null)
|
if (cursor != null)
|
||||||
cursor.hide(player, true);
|
cursor.hide(player, true);
|
||||||
cursor = null;
|
cursor = null;
|
||||||
spawns.forEach(TNTSpawn::hide);
|
spawns.forEach(TNTSpawn::hide);
|
||||||
@ -160,7 +169,11 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showGUI() {
|
public void showGUI() {
|
||||||
List<SWListInv.SWListEntry<TNTSpawn>> swListEntryList = spawns.stream().map(spawn -> {
|
showGUI(spawns);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showGUI(Set<TNTSpawn> tntSpawns) {
|
||||||
|
List<SWListInv.SWListEntry<TNTSpawn>> swListEntryList = tntSpawns.stream().map(spawn -> {
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("§7TNT-Anzahl§8: §e" + spawn.count);
|
lore.add("§7TNT-Anzahl§8: §e" + spawn.count);
|
||||||
lore.add("§7Tick§8: §e" + spawn.tickOffset);
|
lore.add("§7Tick§8: §e" + spawn.tickOffset);
|
||||||
@ -186,12 +199,14 @@ public class TNTSimulator {
|
|||||||
swListInv.open();
|
swListInv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TNTSpawn getEntity(Entity entity){
|
private List<TNTSpawn> getEntity(Entity entity) {
|
||||||
for(TNTSpawn spawn : spawns){
|
List<TNTSpawn> tntSpawns = new ArrayList<>();
|
||||||
if(spawn.entity.getId() == entity.getEntityId())
|
for (TNTSpawn spawn : spawns) {
|
||||||
return spawn;
|
if (spawn.entity.getId() == entity.getEntityId() || spawn.position.equals(entity.getLocation().toVector())) {
|
||||||
|
tntSpawns.add(spawn);
|
||||||
}
|
}
|
||||||
throw new IllegalStateException();
|
}
|
||||||
|
return tntSpawns;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnRandomList(List<TNTSpawn> tntSpawns) {
|
private void spawnRandomList(List<TNTSpawn> tntSpawns) {
|
||||||
@ -202,11 +217,11 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector getPos(RayTraceResult result){
|
private Vector getPos(RayTraceResult result) {
|
||||||
Vector pos = result.getHitPosition();
|
Vector pos = result.getHitPosition();
|
||||||
|
|
||||||
BlockFace face = result.getHitBlockFace();
|
BlockFace face = result.getHitBlockFace();
|
||||||
if(face != null){
|
if (face != null) {
|
||||||
switch (face) {
|
switch (face) {
|
||||||
case DOWN:
|
case DOWN:
|
||||||
pos.setY(pos.getY() - 0.98);
|
pos.setY(pos.getY() - 0.98);
|
||||||
@ -227,14 +242,14 @@ public class TNTSimulator {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(face.getModY() == 0 && !player.isSneaking()){
|
if (face.getModY() == 0 && !player.isSneaking()) {
|
||||||
pos.setY(pos.getY() - 0.49);
|
pos.setY(pos.getY() - 0.49);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.isSneaking()){
|
if (player.isSneaking()) {
|
||||||
pos.setX(pos.getBlockX() + 0.5);
|
pos.setX(pos.getBlockX() + 0.5);
|
||||||
if(face == null || face.getModY() == 0)
|
if (face == null || face.getModY() == 0)
|
||||||
pos.setY(pos.getBlockY() + 0.0);
|
pos.setY(pos.getBlockY() + 0.0);
|
||||||
pos.setZ(pos.getBlockZ() + 0.5);
|
pos.setZ(pos.getBlockZ() + 0.5);
|
||||||
}
|
}
|
||||||
@ -263,15 +278,15 @@ public class TNTSimulator {
|
|||||||
editTNT();
|
editTNT();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void show(){
|
private void show() {
|
||||||
if(printed)
|
if (printed)
|
||||||
return;
|
return;
|
||||||
printed = true;
|
printed = true;
|
||||||
entity.display(player);
|
entity.display(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hide(){
|
private void hide() {
|
||||||
if(!printed)
|
if (!printed)
|
||||||
return;
|
return;
|
||||||
printed = false;
|
printed = false;
|
||||||
entity.hide(player, false);
|
entity.hide(player, false);
|
||||||
@ -287,18 +302,14 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setFuseTicks(int fuseTicks) {
|
private void setFuseTicks(int fuseTicks) {
|
||||||
if (fuseTicks < 0)
|
if (fuseTicks < 0) fuseTicks = 0;
|
||||||
fuseTicks = 0;
|
if (fuseTicks > 160) fuseTicks = 160;
|
||||||
if (fuseTicks > 80)
|
|
||||||
fuseTicks = 80;
|
|
||||||
this.fuseTicks = fuseTicks;
|
this.fuseTicks = fuseTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCount(int count) {
|
private void setCount(int count) {
|
||||||
if(count < 1)
|
if (count < 1) count = 1;
|
||||||
count = 1;
|
if (count > 400) count = 400;
|
||||||
if(count > 400)
|
|
||||||
count = 400;
|
|
||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,10 +318,8 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setTickOffset(int tickOffset) {
|
private void setTickOffset(int tickOffset) {
|
||||||
if(tickOffset < 0)
|
if (tickOffset < 0) tickOffset = 0;
|
||||||
tickOffset = 0;
|
if (tickOffset > 400) tickOffset = 400;
|
||||||
if(tickOffset > 400)
|
|
||||||
tickOffset = 400;
|
|
||||||
this.tickOffset = tickOffset;
|
this.tickOffset = tickOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,10 +329,10 @@ public class TNTSimulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editTNT() {
|
private void editTNT() {
|
||||||
SWInventory swInventory = new SWInventory(player, 27, "TNT konfigurieren");
|
SWInventory swInventory = new SWInventory(player, 54, "TNT konfigurieren");
|
||||||
|
|
||||||
// Change Count of spawned TNT
|
// Change Count of spawned TNT
|
||||||
swInventory.setItem(0, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
|
swInventory.setItem(1, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
|
||||||
setCount(count + 1);
|
setCount(count + 1);
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
@ -332,14 +341,14 @@ public class TNTSimulator {
|
|||||||
editTNT();
|
editTNT();
|
||||||
}, this::editTNT));
|
}, this::editTNT));
|
||||||
countItem.getItemStack().setAmount(count);
|
countItem.getItemStack().setAmount(count);
|
||||||
swInventory.setItem(9, countItem);
|
swInventory.setItem(10, countItem);
|
||||||
swInventory.setItem(18, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
|
swInventory.setItem(19, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
|
||||||
setCount(count - 1);
|
setCount(count - 1);
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Change TickOffset
|
// Change TickOffset
|
||||||
swInventory.setItem(1, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
|
swInventory.setItem(2, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
|
||||||
setTickOffset(tickOffset + 1);
|
setTickOffset(tickOffset + 1);
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
@ -348,14 +357,14 @@ public class TNTSimulator {
|
|||||||
editTNT();
|
editTNT();
|
||||||
}, this::editTNT));
|
}, this::editTNT));
|
||||||
tickItem.getItemStack().setAmount(Math.max(tickOffset, 1));
|
tickItem.getItemStack().setAmount(Math.max(tickOffset, 1));
|
||||||
swInventory.setItem(10, tickItem);
|
swInventory.setItem(11, tickItem);
|
||||||
swInventory.setItem(19, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
|
swInventory.setItem(20, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
|
||||||
setTickOffset(tickOffset - 1);
|
setTickOffset(tickOffset - 1);
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Change FuseTicks
|
// Change FuseTicks
|
||||||
swInventory.setItem(2, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
|
swInventory.setItem(3, new SWItem(SWItem.getDye(10), "§7+1", clickType -> {
|
||||||
setFuseTicks(fuseTicks + 1);
|
setFuseTicks(fuseTicks + 1);
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
@ -364,44 +373,106 @@ public class TNTSimulator {
|
|||||||
editTNT();
|
editTNT();
|
||||||
}, this::editTNT));
|
}, this::editTNT));
|
||||||
fuseTickItem.getItemStack().setAmount(Math.max(fuseTicks, 1));
|
fuseTickItem.getItemStack().setAmount(Math.max(fuseTicks, 1));
|
||||||
swInventory.setItem(11, fuseTickItem);
|
swInventory.setItem(12, fuseTickItem);
|
||||||
swInventory.setItem(20, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
|
swInventory.setItem(21, new SWItem(SWItem.getDye(1), "§7-1", clickType -> {
|
||||||
setFuseTicks(fuseTicks - 1);
|
setFuseTicks(fuseTicks - 1);
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Velocity Settings
|
// Velocity Settings
|
||||||
swInventory.setItem(14, Material.TNT, "TNT", clickType -> {});
|
swInventory.setItem(38, Material.TNT, "TNT", clickType -> {
|
||||||
swInventory.setItem(22, new SWItem(getDye(xVelocity), getColor(xVelocity), "§7TNT §eSprung X §8- " + active(xVelocity), clickType -> {
|
});
|
||||||
|
swInventory.setItem(46, new SWItem(getWool(xVelocity), getColor(xVelocity), "§7TNT §eSprung X §8- " + active(xVelocity), clickType -> {
|
||||||
xVelocity = !xVelocity;
|
xVelocity = !xVelocity;
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
swInventory.setItem(5, new SWItem(getDye(yVelocity), getColor(yVelocity), "§7TNT §eSprung Y §8- " + active(yVelocity), clickType -> {
|
swInventory.setItem(29, new SWItem(getWool(yVelocity), getColor(yVelocity), "§7TNT §eSprung Y §8- " + active(yVelocity), clickType -> {
|
||||||
yVelocity = !yVelocity;
|
yVelocity = !yVelocity;
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
swInventory.setItem(24, new SWItem(getDye(zVelocity), getColor(zVelocity), "§7TNT §eSprung Z §8- " + active(zVelocity), clickType -> {
|
swInventory.setItem(48, new SWItem(getWool(zVelocity), getColor(zVelocity), "§7TNT §eSprung Z §8- " + active(zVelocity), clickType -> {
|
||||||
zVelocity = !zVelocity;
|
zVelocity = !zVelocity;
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Position Settings
|
||||||
|
// X Position
|
||||||
|
swInventory.setItem(5, new SWItem(SWItem.getDye(10), "§7+0,0625", clickType -> {
|
||||||
|
position.add(X_VECTOR);
|
||||||
|
editTNT();
|
||||||
|
}));
|
||||||
|
swInventory.setItem(14, new SWItem(Material.PAPER, "§7x-Position §8- §e" + position.getX(), LORE, false, clickType -> {
|
||||||
|
changePosition(player, position.getX(), x -> {
|
||||||
|
position.setX(clamp(x));
|
||||||
|
editTNT();
|
||||||
|
}, this::editTNT);
|
||||||
|
}));
|
||||||
|
swInventory.setItem(23, new SWItem(SWItem.getDye(1), "§7-0,0625", clickType -> {
|
||||||
|
position.subtract(X_VECTOR);
|
||||||
|
editTNT();
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Y Position
|
||||||
|
swInventory.setItem(6, new SWItem(SWItem.getDye(10), "§7+0,0625", clickType -> {
|
||||||
|
position.add(Y_VECTOR);
|
||||||
|
editTNT();
|
||||||
|
}));
|
||||||
|
swInventory.setItem(15, new SWItem(Material.PAPER, "§7y-Position §8- §e" + position.getY(), LORE, false, clickType -> {
|
||||||
|
changePosition(player, position.getY(), y -> {
|
||||||
|
position.setY(clamp(y));
|
||||||
|
editTNT();
|
||||||
|
}, this::editTNT);
|
||||||
|
}));
|
||||||
|
swInventory.setItem(24, new SWItem(SWItem.getDye(1), "§7-0,0625", clickType -> {
|
||||||
|
position.subtract(Y_VECTOR);
|
||||||
|
editTNT();
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Z Position
|
||||||
|
swInventory.setItem(7, new SWItem(SWItem.getDye(10), "§7+0,0625", clickType -> {
|
||||||
|
position.add(Z_VECTOR);
|
||||||
|
editTNT();
|
||||||
|
}));
|
||||||
|
swInventory.setItem(16, new SWItem(Material.PAPER, "§7z-Position §8- §e" + position.getZ(), LORE, false, clickType -> {
|
||||||
|
changePosition(player, position.getZ(), z -> {
|
||||||
|
position.setZ(clamp(z));
|
||||||
|
editTNT();
|
||||||
|
}, this::editTNT);
|
||||||
|
}));
|
||||||
|
swInventory.setItem(25, new SWItem(SWItem.getDye(1), "§7-0,0625", clickType -> {
|
||||||
|
position.subtract(Z_VECTOR);
|
||||||
|
editTNT();
|
||||||
|
}));
|
||||||
|
|
||||||
// Repeater before Comparator
|
// Repeater before Comparator
|
||||||
swInventory.setItem(8, new SWItem(comparator ? SWItem.getMaterial("REDSTONE_COMPARATOR_OFF") : SWItem.getMaterial("DIODE"), "§7Gezündet durch §8- §e" + (comparator ? "Comparator" : "Repeater"), clickType -> {
|
swInventory.setItem(41, new SWItem(comparator ? SWItem.getMaterial("REDSTONE_COMPARATOR_OFF") : SWItem.getMaterial("DIODE"), "§7Gezündet durch §8- §e" + (comparator ? "Comparator" : "Repeater"), clickType -> {
|
||||||
comparator = !comparator;
|
comparator = !comparator;
|
||||||
editTNT();
|
editTNT();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
swInventory.setItem(17, new SWItem(Material.TNT, "§eZündphase hinzufügen", clickType -> {
|
swInventory.setItem(33, new SWItem(Material.TNT, "§eZündphase hinzufügen", clickType -> {
|
||||||
spawns.add(new TNTSpawn(position, entity));
|
spawns.add(new TNTSpawn(position, entity));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
swInventory.setItem(42, new SWItem(Material.ARROW, "§eZurück", clickType -> {
|
||||||
|
showGUI();
|
||||||
|
}));
|
||||||
|
|
||||||
|
swInventory.setItem(51, new SWItem(Material.DISPENSER, "§eTNT hinzufügen", clickType -> {
|
||||||
|
Vector vector = position.clone();
|
||||||
|
spawns.add(new TNTSpawn(vector, SimulatorEntityShowMode.createEntity(player, vector, false)));
|
||||||
|
}));
|
||||||
|
|
||||||
// Delete tnt
|
// Delete tnt
|
||||||
swInventory.setItem(26, new SWItem(Material.BARRIER, "§cEntfernen", clickType -> {
|
swInventory.setItem(43, new SWItem(Material.BARRIER, "§cEntfernen", clickType -> {
|
||||||
hide();
|
hide();
|
||||||
spawns.remove(this);
|
spawns.remove(this);
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
swInventory.addCloseCallback(clickType -> {
|
||||||
|
TNTSimulator.get(player).show(TNTSimulatorListener.trace(player, player.getLocation()));
|
||||||
|
});
|
||||||
swInventory.open();
|
swInventory.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,8 +489,25 @@ public class TNTSimulator {
|
|||||||
swAnvilInv.open();
|
swAnvilInv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Material getDye(boolean b) {
|
private void changePosition(Player player, double defaultValue, Consumer<Double> result, Runnable failure) {
|
||||||
return SWItem.getDye(getColor(b));
|
SWAnvilInv swAnvilInv = new SWAnvilInv(player, "Position", defaultValue + "");
|
||||||
|
swAnvilInv.setItem(Material.PAPER);
|
||||||
|
swAnvilInv.setCallback(s -> {
|
||||||
|
try {
|
||||||
|
result.accept(Double.parseDouble(s.replace(',', '.')));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
failure.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
swAnvilInv.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double clamp(double d) {
|
||||||
|
return (int) (d * 100) * 0.01;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Material getWool(boolean b) {
|
||||||
|
return b ? Material.LIME_WOOL : Material.RED_WOOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte getColor(boolean b) {
|
private byte getColor(boolean b) {
|
||||||
|
@ -52,7 +52,7 @@ public class TNTSimulatorListener implements Listener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RayTraceResult trace(Player player, Location to) {
|
static RayTraceResult trace(Player player, Location to) {
|
||||||
Location startPos = to.clone().add(0.0, player.getEyeHeight(), 0.0);
|
Location startPos = to.clone().add(0.0, player.getEyeHeight(), 0.0);
|
||||||
Vector direction = to.getDirection();
|
Vector direction = to.getDirection();
|
||||||
RayTraceResult blocks = player.getWorld().rayTraceBlocks(startPos, direction, 10.0, FluidCollisionMode.NEVER, true);
|
RayTraceResult blocks = player.getWorld().rayTraceBlocks(startPos, direction, 10.0, FluidCollisionMode.NEVER, true);
|
||||||
|
@ -44,7 +44,7 @@ public class SimulatorEntityShowMode implements ShowMode<Position> {
|
|||||||
@Override
|
@Override
|
||||||
public void show(Position position) {
|
public void show(Position position) {
|
||||||
RoundedPosition roundedPosition = new RoundedPosition(position);
|
RoundedPosition roundedPosition = new RoundedPosition(position);
|
||||||
AbstractSimulatorEntity entity = entityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true));
|
AbstractSimulatorEntity entity = entityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), false));
|
||||||
entity.display(player);
|
entity.display(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren