diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/DetonatorEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/DetonatorEntity15.java deleted file mode 100644 index efbd29d8..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/DetonatorEntity15.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; -import net.minecraft.server.v1_15_R1.*; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class DetonatorEntity15 extends EntityFallingBlock implements AbstractDetonatorEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - private final Vector position; - private int references = 0; - - public DetonatorEntity15(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.RED_STAINED_GLASS.getBlockData()); - this.position = position; - - this.h(true); - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player) { - if (references++ > 0) - return; - - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(Blocks.RED_STAINED_GLASS.getBlockData()), ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && --references > 0) - return false; - - sendDestroy(player); - die(); - return true; - } - - private void sendDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - } - - @Override - public void sendEntity(Player player) { - display(player); - } - - @Override - public void sendEntityDestroy(Player player) { - hide(player, false); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/entities/SimulatorEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/entities/SimulatorEntity15.java deleted file mode 100644 index 5f828a33..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/entities/SimulatorEntity15.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.shared.BaseEntity15; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class SimulatorEntity15 extends BaseEntity15 implements AbstractSimulatorEntity { - - private boolean printed = false; - - public SimulatorEntity15(World world, Vector position, boolean highlight) { - super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); - - this.setNoGravity(true); - this.ticksLived = -12000; - } - - @Override - public void display(Player player) { - if (printed) return; - printed = true; - - sendEntity(player); - } - - @Override - public void setPosition(Vector position) { - this.position = position; - setPosition(position.getX(), position.getY(), position.getZ()); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!printed) return false; - printed = false; - - - sendEntityDestroy(player); - die(); - return true; - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java b/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java deleted file mode 100644 index f3e38be3..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import de.steamwar.bausystem.features.tracer.show.Record; - -public class SimulatorPreview15 implements SimulatorPreview { - - @Override - public Record simulate(TNTSimulator tntSimulator) { - return new Record(null); - } -} diff --git a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java b/BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java deleted file mode 100644 index 66480122..00000000 --- a/BauSystem_15/src/de/steamwar/bausystem/shared/BaseEntity15.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.server.v1_15_R1.*; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseEntity15 extends EntityFallingBlock implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - private final IBlockData iBlockData; - protected Vector position; - - public BaseEntity15(World world, Vector position, Material blockType) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState()); - this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState(); - this.position = position; - - this.setNoGravity(true); - this.ticksLived = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), getUniqueID(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.FALLING_BLOCK, Block.getCombinedId(iBlockData), ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; - playerConnection.sendPacket(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); - playerConnection.sendPacket(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java deleted file mode 100644 index 8b28359e..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/DetonatorEntity18.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.item.EntityFallingBlock; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class DetonatorEntity18 extends EntityFallingBlock implements AbstractDetonatorEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - private final Vector position; - private int references = 0; - - public DetonatorEntity18(World world, Vector position) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), Blocks.du.n()); - this.position = position; - - this.h(true); - this.e(true); - this.S = -12000; - } - - @Override - public int getId() { - return ae(); - } - - @Override - public void display(Player player) { - if (references++ > 0) - return; - - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(getId(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(Blocks.du.n()), ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && --references > 0) - return false; - - sendDestroy(player); - ag(); - return true; - } - - private void sendDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } - - @Override - public void sendEntity(Player player) { - display(player); - } - - @Override - public void sendEntityDestroy(Player player) { - hide(player, false); - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java deleted file mode 100644 index 58537b7b..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/entities/SimulatorEntity18.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.shared.BaseEntity18; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class SimulatorEntity18 extends BaseEntity18 implements AbstractSimulatorEntity { - - private boolean printed = false; - - public SimulatorEntity18(World world, Vector position, boolean highlight) { - super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); - - this.e(true); - this.S = -12000; - } - - @Override - public int getId() { - return ae(); - } - - @Override - public void display(Player player) { - if (printed) return; - printed = true; - - sendEntity(player); - } - - @Override - public void setPosition(Vector position) { - this.position = position; - e(position.getX(), position.getY(), position.getZ()); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!printed) return false; - printed = false; - - sendEntityDestroy(player); - ag(); - return true; - } -} diff --git a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java b/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java deleted file mode 100644 index ef776851..00000000 --- a/BauSystem_18/src/de/steamwar/bausystem/shared/BaseEntity18.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.item.EntityFallingBlock; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; -import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class BaseEntity18 extends EntityFallingBlock implements AbstractEntity { - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - private final IBlockData iBlockData; - protected Vector position; - - public BaseEntity18(World world, Vector position, Material blockType) { - super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), ((CraftBlockData) blockType.createBlockData()).getState()); - this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState(); - this.position = position; - - this.e(true); - this.S = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), cm(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.C, Block.i(iBlockData), ZERO); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java deleted file mode 100644 index 15b622ac..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/DetonatorEntity19.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.item.EntityFallingBlock; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.lang.reflect.Field; - -public class DetonatorEntity19 extends EntityFallingBlock implements AbstractDetonatorEntity { - - private static final Field ao; - - static { - try { - ao = EntityFallingBlock.class.getDeclaredField("ao"); - ao.setAccessible(true); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - private final Vector position; - private int references = 0; - private IBlockData iBlockData; - - public DetonatorEntity19(World world, Vector position) { - super(EntityTypes.E, ((CraftWorld) world).getHandle()); - try { - ao.set(this, ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState()); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - this.q = true; - e(position.getX(), position.getY(), position.getZ()); - f(Vec3D.b); - t = position.getX(); - u = position.getY(); - v = position.getZ(); - a(this.db()); - - this.iBlockData = ((CraftBlockData) Material.RED_STAINED_GLASS.createBlockData()).getState(); - this.position = position; - - this.e(true); - this.S = -12000; - } - - @Override - public int getId() { - return ae(); - } - - @Override - public void display(Player player) { - if (references++ > 0) - return; - - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!force && --references > 0) - return false; - - sendDestroy(player); - ag(); - return true; - } - - private void sendDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } - - @Override - public void sendEntity(Player player) { - display(player); - } - - @Override - public void sendEntityDestroy(Player player) { - hide(player, false); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/SimulatorEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/SimulatorEntity19.java deleted file mode 100644 index 51d3e6eb..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/SimulatorEntity19.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.entities; - -import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.shared.BaseEntity19; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public class SimulatorEntity19 extends BaseEntity19 implements AbstractSimulatorEntity { - - private boolean printed = false; - - public SimulatorEntity19(World world, Vector position, boolean highlight) { - super(world, position, highlight ? Material.WHITE_STAINED_GLASS : Material.TNT); - - this.e(true); - this.S = -12000; - } - - @Override - public int getId() { - return ae(); - } - - @Override - public void display(Player player) { - if (printed) return; - printed = true; - - sendEntity(player); - } - - @Override - public void setPosition(Vector position) { - this.position = position; - e(position.getX(), position.getY(), position.getZ()); - } - - @Override - public boolean hide(Player player, boolean force) { - if (!printed) return false; - printed = false; - - sendEntityDestroy(player); - ag(); - return true; - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeExplosion19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeExplosion19.java deleted file mode 100644 index eaa19495..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeExplosion19.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import com.google.common.collect.Maps; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import net.minecraft.core.BlockPosition; -import net.minecraft.util.RandomSource; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.EntityHuman; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.ExplosionDamageCalculator; -import net.minecraft.world.level.World; -import net.minecraft.world.level.gameevent.GameEvent; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory; - -import javax.annotation.Nullable; -import java.util.List; -import java.util.Map; - -public class FakeExplosion19 extends Explosion { - - private List fakeTNT19s; - private boolean c; - private Explosion.Effect d; - private RandomSource e; - private World f; - private double g; - private double h; - private double i; - @Nullable - public Entity j; - private float k; - private DamageSource l; - private ExplosionDamageCalculator m; - private ObjectArrayList n; - private Map o; - public boolean wasCanceled; - - public FakeExplosion19(List fakeTNT19s, World world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) { - super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType); - this.fakeTNT19s = fakeTNT19s; - this.wasCanceled = false; - this.e = RandomSource.a(); - this.n = new ObjectArrayList(); - this.o = Maps.newHashMap(); - this.f = world; - this.j = entity; - this.k = (float) Math.max((double) power, 0.0D); - this.g = x; - this.h = y; - this.i = z; - this.c = createFire; - this.d = destructionType; - this.l = damageSource == null ? DamageSource.a(this) : damageSource; - this.m = new ExplosionDamageCalculator(); - - } - - private float getBlockDensity(Vec3D vec3d, Entity entity) { - return a(vec3d, entity); - } - - - @Override - public void a() { - if ((this.k) >= 0.1F) { - this.f.a(this.j, GameEvent.w, new Vec3D(this.g, this.h, this.i)); - /* - Set set = Sets.newHashSet(); - - int i; - int j; - for (int k = 0; k < 16; ++k) { - for (i = 0; i < 16; ++i) { - for (j = 0; j < 16; ++j) { - if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) { - double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F); - double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F); - double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F); - double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); - d0 /= d3; - d1 /= d3; - d2 /= d3; - float f = this.k * (0.7F + this.f.w.i() * 0.6F); - double d4 = this.g; - double d5 = this.h; - double d6 = this.i; - - for (float var21 = 0.3F; f > 0.0F; f -= 0.22500001F) { - BlockPosition blockposition = new BlockPosition(d4, d5, d6); - IBlockData iblockdata = this.f.a_(blockposition); - Fluid fluid = iblockdata.p(); - if (!this.f.j(blockposition)) { - break; - } - - Optional optional = this.m.a(this, this.f, blockposition, iblockdata, fluid); - if (optional.isPresent()) { - f -= ((Float) optional.get() + 0.3F) * 0.3F; - } - - if (f > 0.0F && this.m.a(this, this.f, blockposition, iblockdata, f)) { - set.add(blockposition); - } - - d4 += d0 * 0.30000001192092896D; - d5 += d1 * 0.30000001192092896D; - d6 += d2 * 0.30000001192092896D; - } - } - } - } - } - - this.n.addAll(set); - */ - - float f2 = this.k * 2.0F; - Vec3D vec3d = new Vec3D(this.g, this.h, this.i); - for (int l1 = 0; l1 < fakeTNT19s.size(); ++l1) { - Entity entity = (Entity) fakeTNT19s.get(l1); - if (!entity.cF()) { - double d7 = Math.sqrt(entity.e(vec3d)) / (double) f2; - if (d7 <= 1.0D) { - double d8 = entity.df() - this.g; - double d9 = entity.dh() - this.h; - double d10 = entity.dl() - this.i; - double d11 = Math.sqrt(d8 * d8 + d9 * d9 + d10 * d10); - if (d11 != 0.0D) { - d8 /= d11; - d9 /= d11; - d10 /= d11; - double d12 = (double) this.getBlockDensity(vec3d, entity); - - double d13 = (1.0D - d7) * d12; - entity.lastDamageCancelled = false; - CraftEventFactory.entityDamage = null; - entity.f(entity.dd().b(d8 * d13, d9 * d13, d10 * d13)); - } - } - } - } - } - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java deleted file mode 100644 index abf89c09..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/FakeTNT19.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import net.minecraft.core.BlockPosition; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.protocol.Packet; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.network.syncher.DataWatcher; -import net.minecraft.network.syncher.DataWatcherObject; -import net.minecraft.network.syncher.DataWatcherRegistry; -import net.minecraft.util.MathHelper; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.*; -import net.minecraft.world.entity.item.EntityTNTPrimed; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.ExplosionDamageCalculator; -import net.minecraft.world.level.World; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.phys.AxisAlignedBB; -import net.minecraft.world.phys.Vec3D; -import net.minecraft.world.phys.shapes.VoxelShape; -import org.bukkit.entity.Explosive; -import org.bukkit.event.entity.ExplosionPrimeEvent; - -import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; - -public class FakeTNT19 extends EntityTNTPrimed { - private static final DataWatcherObject b; - private static final int c = 80; - private List fakeTNT19s; - private List spawnList = new ArrayList<>(); - private int count; - @Nullable - public EntityLiving d; - public float yield; - public boolean isIncendiary; - - public FakeTNT19(List fakeTNT19s, EntityTypes type, World world) { - super(type, world); - this.fakeTNT19s = fakeTNT19s; - this.yield = 4.0F; - this.isIncendiary = false; - super.q = true; - } - - public FakeTNT19(List fakeTNT19s, World world, double x, double y, double z, int fuse, int count) { - this(fakeTNT19s, EntityTypes.av, world); - this.e(x, y, z); - double d3 = world.w.j() * 6.2831854820251465D; - this.n(-Math.sin(d3) * 0.02D, 0.20000000298023224D, -Math.cos(d3) * 0.02D); - this.a(fuse); - super.t = x; - super.u = y; - super.v = z; - this.d = null; - this.count = count; - } - - protected void a_() { - super.Y.a(b, 80); - } - - protected MovementEmission aO() { - return MovementEmission.a; - } - - public boolean bl() { - return !this.dt(); - } - - private Vec3D g(Vec3D vec3d) { - AxisAlignedBB axisalignedbb = this.cz(); - List list = this.s.b(this, axisalignedbb.b(vec3d)); - Vec3D vec3d1 = vec3d.g() == 0.0 ? vec3d : a(this, vec3d, axisalignedbb, this.s, list); - boolean flag = vec3d.c != vec3d1.c; - boolean flag1 = vec3d.d != vec3d1.d; - boolean flag2 = vec3d.e != vec3d1.e; - boolean flag3 = this.y || flag1 && vec3d.d < 0.0; - if (this.P > 0.0F && flag3 && (flag || flag2)) { - Vec3D vec3d2 = a(this, new Vec3D(vec3d.c, (double)this.P, vec3d.e), axisalignedbb, this.s, list); - Vec3D vec3d3 = a(this, new Vec3D(0.0, (double)this.P, 0.0), axisalignedbb.b(vec3d.c, 0.0, vec3d.e), this.s, list); - if (vec3d3.d < (double)this.P) { - Vec3D vec3d4 = a(this, new Vec3D(vec3d.c, 0.0, vec3d.e), axisalignedbb.c(vec3d3), this.s, list).e(vec3d3); - if (vec3d4.i() > vec3d2.i()) { - vec3d2 = vec3d4; - } - } - - if (vec3d2.i() > vec3d1.i()) { - return vec3d2.e(a(this, new Vec3D(0.0, -vec3d2.d + vec3d.d, 0.0), axisalignedbb.c(vec3d2), this.s, list)); - } - } - - return vec3d1; - } - - @Override - public void a(EnumMoveType enummovetype, Vec3D vec3d) { - if (this.E.g() > 1.0E-7) { - vec3d = vec3d.h(this.E); - this.E = Vec3D.b; - this.f(Vec3D.b); - } - - Vec3D vec3d1 = this.g(vec3d); - double d0 = vec3d1.g(); - if (d0 > 1.0E-7) { - this.e(this.df() + vec3d1.c, this.dg() + vec3d1.d, this.dl() + vec3d1.e); - } - - boolean flag = !MathHelper.b(vec3d.c, vec3d1.c); - boolean flag1 = !MathHelper.b(vec3d.e, vec3d1.e); - this.z = flag || flag1; - this.A = vec3d.d != vec3d1.d; - this.B = this.A && vec3d.d < 0.0; - if (this.z) { - this.C = this.b(vec3d1); - } else { - this.C = false; - } - - this.y = this.A && vec3d.d < 0.0; - BlockPosition blockposition = this.aA(); - IBlockData iblockdata = this.s.a_(blockposition); - // this.a(vec3d1.d, this.y, iblockdata, blockposition); - if (!this.dt()) { - if (this.z) { - Vec3D vec3d2 = this.dd(); - this.n(flag ? 0.0 : vec3d2.c, vec3d2.d, flag1 ? 0.0 : vec3d2.e); - } - - net.minecraft.world.level.block.Block block = iblockdata.b(); - if (vec3d.d != vec3d1.d) { - block.a(this.s, this); - } - - if (this.y) { - block.a(this.s, blockposition, iblockdata, this); - } - - this.ax(); - float f2 = this.aD(); - this.f(this.dd().d((double)f2, 1.0, (double)f2)); - } - } - - public void k(List spawnList) { - if (!this.aN()) { - this.f(this.dd().b(0.0D, -0.04D, 0.0D)); - } - - this.a(EnumMoveType.a, this.dd()); - this.f(this.dd().a(0.98D)); - if (super.y) { - this.f(this.dd().d(0.7D, -0.5D, 0.7D)); - } - - int i = this.i() - 1; - this.a(i); - if (i <= 0) { - if (!super.s.y) { - this.j1(); - } - - this.ah(); - } else { - this.aY(); - } - - if (i == 1 && count > 1) { - for (int c = 0; c < count - 1; c++) { - FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, this.s, this.df(), this.dh(), this.dl(), i, 1); - fakeTNT19.y = this.y; - fakeTNT19.f(new Vec3D(this.dd().c, this.dd().d, this.dd().e)); - spawnList.add(fakeTNT19); - } - count = 1; - } - } - - private void j1() { - ExplosionPrimeEvent event = new ExplosionPrimeEvent((Explosive) this.getBukkitEntity()); - super.s.getCraftServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - this.a(this, this.df(), this.e(0.0625D), this.dl(), event.getRadius(), event.getFire(), Explosion.Effect.b); - } - } - - public FakeExplosion19 a(@Nullable Entity entity, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) { - return this.a(entity, (DamageSource) null, (ExplosionDamageCalculator) null, x, y, z, power, createFire, destructionType); - } - - public FakeExplosion19 a(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.Effect destructionType) { - FakeExplosion19 explosion = new FakeExplosion19(fakeTNT19s, SimulatorPreview19.WORLD, entity, damageSource, behavior, x, y, z, power, createFire, destructionType); - explosion.a(); - // explosion.a(true); - return explosion; - } - - - protected void b(NBTTagCompound nbt) { - nbt.a("Fuse", (short) this.i()); - } - - protected void a(NBTTagCompound nbt) { - this.a(nbt.g("Fuse")); - } - - @Nullable - public EntityLiving h() { - return this.d; - } - - protected float a(EntityPose pose, EntitySize dimensions) { - return 0.15F; - } - - public void a(int fuse) { - super.Y.b(b, fuse); - } - - public int i() { - return (Integer) super.Y.a(b); - } - - public Packet S() { - return new PacketPlayOutSpawnEntity(this); - } - - public boolean cr() { - return super.cr(); - } - - static { - b = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b); - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java deleted file mode 100644 index 5a06c342..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.shared.Pair; -import net.minecraft.world.level.World; -import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.entity.TNTPrimed; - -import java.util.*; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -public class SimulatorPreview19 implements SimulatorPreview { - - public static final World WORLD = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle(); - - @Override - public Record simulate(TNTSimulator tntSimulator) { - if (true) { - return new Record(null); - } - - Map>>> result = new HashMap<>(); - for (SimulatorElement element : tntSimulator.getTntElementList()) { - element.locations(result); - } - - AtomicInteger maxTick = new AtomicInteger(0); - Map>>> toSpawn = new HashMap<>(); - AtomicInteger tntCount = new AtomicInteger(0); - result.forEach((integer, integerSetMap) -> { - List>>> internal = new ArrayList<>(); - integerSetMap.forEach((integer1, pairs) -> { - internal.add(new Pair<>(integer1, pairs)); - }); - internal.sort(Comparator.comparingInt(Pair::getKey)); - - toSpawn.put(integer, internal.stream().map(Pair::getValue).peek(pairs -> { - tntCount.addAndGet(pairs.stream().mapToInt(Pair::getValue).sum()); - }).map(ArrayList::new).peek(Collections::shuffle).collect(Collectors.toList())); - - if (maxTick.get() < integer) { - maxTick.set(integer); - } - }); - if (tntCount.get() > 500) { - return new Record(null); - } - - List fakeTNT19s = new ArrayList<>(); - Record record = new Record(null); - Map tntRecords = new HashMap<>(); - - int maxTickToCalc = maxTick.get() + 160; - for (int tick = 0; tick < maxTickToCalc; tick++) { - List>> toSpawnInTick = toSpawn.get(tick); - try { - if (toSpawnInTick == null) continue; - toSpawnInTick.forEach(pairs -> { - AtomicBoolean hasSomeLeft = new AtomicBoolean(true); - while(hasSomeLeft.get()) { - hasSomeLeft.set(false); - pairs.forEach(pair -> { - SimulatorPreview.SimulatorPreviewTNTData previewTNTData = pair.getKey(); - if (!previewTNTData.isXVelocity() && !previewTNTData.isZVelocity()) { - FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), pair.getValue()); - TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity(); - if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0)); - if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0)); - if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0)); - fakeTNT19s.add(fakeTNT19); - pair.setValue(0); - } else if (pair.getValue() > 0) { - hasSomeLeft.set(true); - FakeTNT19 fakeTNT19 = new FakeTNT19(fakeTNT19s, WORLD, previewTNTData.getX(), previewTNTData.getY(), previewTNTData.getZ(), previewTNTData.getFuseTicks(), 1); - TNTPrimed tntPrimed = (TNTPrimed) fakeTNT19.getBukkitEntity(); - if (!previewTNTData.isXVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setX(0)); - if (!previewTNTData.isYVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setY(0)); - if (!previewTNTData.isZVelocity()) tntPrimed.setVelocity(tntPrimed.getVelocity().setZ(0)); - fakeTNT19s.add(fakeTNT19); - pair.setValue(pair.getValue() - 1); - } - }); - } - }); - } finally { - calculateTick(fakeTNT19s, record, tntRecords); - } - } - return record; - } - - private void calculateTick(List fakeTNT19s, Record record, Map tntRecords) { - int i = 0; - while (i < fakeTNT19s.size()) { - List spawnList = new ArrayList<>(); - FakeTNT19 fakeTNT19 = fakeTNT19s.get(i); - fakeTNT19.k(spawnList); - TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity())); - if (tntPrimed.getFuseTicks() <= 0) { - tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed); - fakeTNT19s.remove(i); - i--; - } else { - tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed); - } - if (!spawnList.isEmpty()) { - fakeTNT19s.addAll(i, spawnList); - i += spawnList.size(); - } - i++; - } - } -} diff --git a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java deleted file mode 100644 index df65d56a..00000000 --- a/BauSystem_19/src/de/steamwar/bausystem/shared/BaseEntity19.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import net.minecraft.network.protocol.game.PacketPlayOutEntityDestroy; -import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata; -import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity; -import net.minecraft.server.network.PlayerConnection; -import net.minecraft.world.entity.EntityTypes; -import net.minecraft.world.entity.item.EntityFallingBlock; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.IBlockData; -import net.minecraft.world.phys.Vec3D; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData; -import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.lang.reflect.Field; - -public class BaseEntity19 extends EntityFallingBlock implements AbstractEntity { - - private static final Field ao; - - static { - try { - ao = EntityFallingBlock.class.getDeclaredField("ao"); - ao.setAccessible(true); - } catch (NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - - private static final Vec3D ZERO = new Vec3D(0, 0, 0); - - private final IBlockData iBlockData; - protected Vector position; - - public BaseEntity19(World world, Vector position, Material blockType) { - super(EntityTypes.E, ((CraftWorld) world).getHandle()); - try { - ao.set(this, ((CraftBlockData) blockType.createBlockData()).getState()); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - this.q = true; - e(position.getX(), position.getY(), position.getZ()); - f(Vec3D.b); - t = position.getX(); - u = position.getY(); - v = position.getZ(); - a(this.db()); - - this.iBlockData = ((CraftBlockData) blockType.createBlockData()).getState(); - this.position = position; - - this.e(true); - this.S = -12000; - } - - public void sendEntity(Player player) { - PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(ae(), co(), position.getX(), position.getY(), position.getZ(), 0, 0, EntityTypes.E, Block.i(iBlockData), ZERO, 0.0); - PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().b; - playerConnection.a(packetPlayOutSpawnEntity); - - PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(ae(), Y, true); - playerConnection.a(packetPlayOutEntityMetadata); - } - - public void sendEntityDestroy(Player player) { - PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(ae()); - ((CraftPlayer) player).getHandle().b.a(packetPlayOutEntityDestroy); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/AbstractDetonatorEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/AbstractDetonatorEntity.java deleted file mode 100644 index 1f1a5b8b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/AbstractDetonatorEntity.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.detonator; - -import de.steamwar.bausystem.shared.AbstractEntity; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -public interface AbstractDetonatorEntity extends AbstractEntity { - - void display(Player player); - - boolean hide(Player player, boolean always); - - int getId(); - - Entity getBukkitEntity(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java index c1ffd756..9e68f016 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/Detonator.java @@ -26,6 +26,9 @@ import de.steamwar.bausystem.features.autostart.AutostartListener; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; import de.steamwar.bausystem.features.detonator.storage.ItemStorage; import de.steamwar.bausystem.utils.NMSWrapper; +import de.steamwar.entity.REntity; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RFallingBlockEntity; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -44,7 +47,7 @@ import java.util.*; @UtilityClass public class Detonator { - private static final Map> ENTITIES_MAP = new HashMap<>(); + private static final Map ENTITIES_MAP = new HashMap<>(); private static final Vector HALF = new Vector(0.5, 0, 0.5); public static boolean isDetonator(ItemStack itemStack) { @@ -52,18 +55,19 @@ public class Detonator { } public static void showDetonator(Player p, List locs) { - List entities = new LinkedList<>(); - locs.stream().map(Location::toVector).forEach(vector -> entities.add(NMSWrapper.impl.constructDetonator(p.getWorld(), vector.add(HALF)))); - entities.forEach(abstractDetonatorEntity -> abstractDetonatorEntity.display(p)); - ENTITIES_MAP.putIfAbsent(p, entities); + if (ENTITIES_MAP.containsKey(p)) return; + REntityServer entities = new REntityServer(); + entities.addPlayer(p); + ENTITIES_MAP.put(p, entities); + + locs.forEach(location -> { + RFallingBlockEntity entity = new RFallingBlockEntity(entities, location.clone().add(HALF), Material.RED_STAINED_GLASS); + entity.setNoGravity(true); + }); } public static void hideDetonator(Player p) { - ENTITIES_MAP.remove(p).forEach(abstractDetonatorEntity -> abstractDetonatorEntity.hide(p, true)); - } - - public static List getDetoEntities(Player p) { - return ENTITIES_MAP.getOrDefault(p, new ArrayList<>()); + ENTITIES_MAP.remove(p).close(); } public static boolean hasActiveDetonatorShow(Player p) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java index 2e0cbf38..f7577e14 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java @@ -19,8 +19,6 @@ package de.steamwar.bausystem.features.detonator; -import com.comphenix.tinyprotocol.Reflection; -import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; @@ -38,38 +36,13 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerSwapHandItemsEvent; import java.util.HashSet; -import java.util.List; import java.util.Set; @Linked public class DetonatorListener implements Listener { - public static final Class useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity"); - private static final Reflection.FieldAccessor entityIdFieldAccessor = Reflection.getField(useEntity, int.class, 0); - private static final Set HAS_UPDATED = new HashSet<>(); - public DetonatorListener() { - TinyProtocol.instance.addFilter(useEntity, (player, o) -> { - List entities = Detonator.getDetoEntities(player); - if (entities.isEmpty()) { - return o; - } - - int entityId = entityIdFieldAccessor.get(o); - AbstractDetonatorEntity entity = entities.stream().filter(abstractDetonatorEntity -> abstractDetonatorEntity.getId() == entityId).findFirst().orElse(null); - - if (entity == null) { - return o; - } - - Location location = entity.getBukkitEntity().getLocation().getBlock().getLocation(); - addLocationToDetonator(location, player); - HAS_UPDATED.add(player); - return null; - }); - } - private static void addLocationToDetonator(Location location, Player p) { Detoblock detoblock = Detonator.getBlock(location.getBlock()); if (detoblock == Detoblock.INVALID) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java deleted file mode 100644 index faf81588..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/AbstractSimulatorEntity.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import de.steamwar.bausystem.shared.AbstractEntity; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -public interface AbstractSimulatorEntity extends AbstractEntity { - - void display(Player player); - - void setPosition(Vector position); - - boolean hide(Player player, boolean always); - - int getId(); - - Entity getBukkitEntity(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index fcc11942..cc3873f2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -20,13 +20,17 @@ package de.steamwar.bausystem.features.simulator; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; +import de.steamwar.bausystem.utils.RayTraceUtils; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RFallingBlockEntity; import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; -import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; import java.util.HashMap; @@ -36,13 +40,14 @@ import java.util.Map; @UtilityClass public class SimulatorCursor { - private Map cursors = new HashMap<>(); + private static final World WORLD = Bukkit.getWorlds().get(0); + private Map rEntityServerMap = new HashMap<>(); - public void show(Player player, TNTSimulator tntSimulator, RayTraceResult result) { - AbstractSimulatorEntity cursor = cursors.get(player); + public void show(Player player, TNTSimulator tntSimulator, RayTraceUtils.RRayTraceResult result) { + REntityServer cursor = rEntityServerMap.get(player); if (cursor != null) - cursor.hide(player, false); + cursor.close(); tntSimulator.show(player); @@ -53,9 +58,11 @@ public class SimulatorCursor { List elements = tntSimulator.getEntity(result.getHitEntity()); tntSimulator.hide(player, elements); - cursor = SimulatorEntityShowMode.createEntity(elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition(), true); - cursor.display(player); - cursors.put(player, cursor); + cursor = new REntityServer(); + RFallingBlockEntity entity = new RFallingBlockEntity(cursor, (elements.isEmpty() ? getPos(player, result) : elements.get(0).getPosition()).toLocation(WORLD), Material.WHITE_STAINED_GLASS); + entity.setNoGravity(true); + cursor.addPlayer(player); + rEntityServerMap.put(player, cursor); BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_EDIT", player, ChatMessageType.ACTION_BAR); return; } @@ -64,25 +71,27 @@ public class SimulatorCursor { return; } - cursor = SimulatorEntityShowMode.createEntity(getPos(player, result), false); - cursor.display(player); - cursors.put(player, cursor); + cursor = new REntityServer(); + RFallingBlockEntity entity = new RFallingBlockEntity(cursor, getPos(player, result).toLocation(WORLD), Material.TNT); + entity.setNoGravity(true); + cursor.addPlayer(player); + rEntityServerMap.put(player, cursor); BauSystem.MESSAGE.sendPrefixless("SIMULATOR_POSITION_ADD", player, ChatMessageType.ACTION_BAR); } public void hide(Player player, TNTSimulator tntSimulator) { - AbstractSimulatorEntity cursor = cursors.get(player); + REntityServer cursor = rEntityServerMap.get(player); if (cursor != null) - cursor.hide(player, false); + cursor.close(); if (tntSimulator != null) { - tntSimulator.remove(player); + tntSimulator.hide(player); } - cursors.remove(player); + rEntityServerMap.remove(player); } - public static Vector getPos(Player player, RayTraceResult result) { + public static Vector getPos(Player player, RayTraceUtils.RRayTraceResult result) { Vector pos = result.getHitPosition(); BlockFace face = result.getHitBlockFace(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreview.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreview.java deleted file mode 100644 index 422bb075..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreview.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.core.VersionDependent; -import lombok.AllArgsConstructor; -import lombok.Data; - -public interface SimulatorPreview { - SimulatorPreview impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); - - @Data - @AllArgsConstructor - class SimulatorPreviewTNTData { - private double x; - private double y; - private double z; - private int fuseTicks; - private boolean xVelocity; - private boolean yVelocity; - private boolean zVelocity; - } - - Record simulate(TNTSimulator tntSimulator); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java deleted file mode 100644 index 363a9162..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorPreviewStorage.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.simulator; - -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.features.tracer.show.EntityShowMode; -import de.steamwar.bausystem.shared.Pair; -import de.steamwar.bausystem.shared.ShowMode; -import lombok.experimental.UtilityClass; -import org.bukkit.entity.Player; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -@UtilityClass -public class SimulatorPreviewStorage { - private Map>> previews = new HashMap<>(); - private Map>> showModes = new HashMap<>(); - - public void show(Player player, TNTSimulator tntSimulator) { - if (showModes.containsKey(player)) { - Pair> pair = showModes.get(player); - if (pair.getKey() != tntSimulator) { - pair.getValue().hide(); - Pair> setPair = previews.get(pair.getKey()); - setPair.getValue().remove(player); - if (setPair.getValue().isEmpty()) { - previews.remove(pair.getKey()); - } - } else { - return; - } - } - - Pair> pair = previews.computeIfAbsent(tntSimulator, k -> new Pair<>(SimulatorPreview.impl.simulate(k), new HashSet<>())); - pair.getValue().add(player); - - ShowModeParameter showModeParameter = new ShowModeParameter(); - EntityShowMode showMode = new EntityShowMode(player, showModeParameter, 10); - pair.getKey().showAll(showMode); - showModes.put(player, new Pair<>(tntSimulator, showMode)); - } - - public void hide(Player player) { - if (showModes.containsKey(player)) { - Pair> pair = showModes.get(player); - pair.getValue().hide(); - Pair> setPair = previews.get(pair.getKey()); - setPair.getValue().remove(player); - if (setPair.getValue().isEmpty()) { - previews.remove(pair.getKey()); - } - showModes.remove(player); - } - } - - public void recalculate(TNTSimulator tntSimulator) { - Pair> pair = previews.get(tntSimulator); - if (pair == null) return; - pair.setKey(SimulatorPreview.impl.simulate(tntSimulator)); - pair.getValue().forEach(player -> { - Pair> setPair = showModes.get(player); - setPair.getValue().hide(); - pair.getKey().showAll(setPair.getValue()); - }); - } - - public void recalculateAll() { - previews.keySet().forEach(SimulatorPreviewStorage::recalculate); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index 4a92058a..27988cdc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -31,12 +31,13 @@ import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; +import de.steamwar.bausystem.utils.RayTraceUtils; +import de.steamwar.entity.REntityServer; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import org.bukkit.util.RayTraceResult; import yapion.hierarchy.types.YAPIONArray; import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONType; @@ -49,7 +50,8 @@ import java.util.stream.Collectors; @Getter public class TNTSimulator { - private Map playerShowMode = new HashMap<>(); + private Set players = new HashSet<>(); + private REntityServer entityServer = new REntityServer(); private Material material = Material.TNT; @@ -82,38 +84,13 @@ public class TNTSimulator { return yapionObject; } - public void hide() { - playerShowMode.forEach((player, simulatorEntityShowMode) -> { - simulatorEntityShowMode.hide(); - }); - } - - public void show() { - playerShowMode.forEach((player, simulatorEntityShowMode) -> { - for (SimulatorElement element : tntElementList) { - element.show(simulatorEntityShowMode); - } - }); + public void close() { + entityServer.close(); } public void hide(Player player) { - SimulatorEntityShowMode showMode = playerShowMode.get(player); - if (showMode == null) { - return; - } - tntElementList.forEach(simulatorElement -> { - simulatorElement.hide(showMode); - }); - } - - public void remove(Player player) { - SimulatorEntityShowMode showMode = playerShowMode.remove(player); - if (showMode == null) { - return; - } - tntElementList.forEach(simulatorElement -> { - simulatorElement.hide(showMode); - }); + entityServer.removePlayer(player); + players.remove(player); } public void hide(Player player, List simulatorElements) { @@ -133,10 +110,8 @@ public class TNTSimulator { } public void show(Player player) { - SimulatorEntityShowMode showMode = playerShowMode.computeIfAbsent(player, SimulatorEntityShowMode::new); - tntElementList.forEach(simulatorElement -> { - simulatorElement.show(showMode); - }); + entityServer.addPlayer(player); + players.add(player); } public void show(SimulatorElement simulatorElement) { @@ -185,7 +160,7 @@ public class TNTSimulator { }); } - public void edit(Player player, RayTraceResult result) { + public void edit(Player player, RayTraceUtils.RRayTraceResult result) { if (result == null) { TNTSimulatorGui.open(player, this, null, this::getTntElementList, null); return; @@ -212,9 +187,6 @@ public class TNTSimulator { TNTElement tntElement = new TNTElement(SimulatorCursor.getPos(player, result)); tntElementList.add(tntElement); TNTElementGUI.open(player, tntElement, null); - playerShowMode.forEach((p, simulatorEntityShowMode) -> { - show(p); - }); } public void start(Player p) { @@ -230,7 +202,7 @@ public class TNTSimulator { } AtomicBoolean needsAutoTrace = new AtomicBoolean(); - playerShowMode.forEach((player, simulatorEntityShowMode) -> { + players.forEach(player -> { boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false); if (simulatorAutoTrace) { needsAutoTrace.set(true); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java index d057fd76..491f37c6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java @@ -25,13 +25,10 @@ import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.bausystem.utils.RayTraceUtils; import de.steamwar.linkage.Linked; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.player.*; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; @@ -50,19 +47,14 @@ public class TNTSimulatorListener implements Listener { return true; } - static RayTraceResult trace(Player player, Location to, TNTSimulator simulator) { - return RayTraceUtils.trace(player, to, simulator.getEntities()); + static RayTraceUtils.RRayTraceResult trace(Player player, Location to, TNTSimulator simulator) { + return RayTraceUtils.traceREntity(player, to, simulator.getEntities()); } @EventHandler public void onPlayerMove(PlayerMoveEvent e) { if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) { simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getTo()); - TNTSimulator tntSimulator = SimulatorStorage.getSimulator(e.getPlayer().getInventory().getItemInOffHand()); - if (tntSimulator == null) SimulatorPreviewStorage.hide(e.getPlayer()); - } else { - TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getTo()); - if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator); } } @@ -91,11 +83,6 @@ public class TNTSimulatorListener implements Listener { public void onPlayerJoin(PlayerJoinEvent e) { if (ItemUtils.isItem(e.getPlayer().getInventory().getItemInMainHand(), "simulator")) { simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInMainHand, e.getPlayer().getLocation()); - } else { - TNTSimulator tntSimulator = simulatorShowHide(e.getPlayer(), i -> null, PlayerInventory::getItemInOffHand, e.getPlayer().getLocation()); - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { - if (tntSimulator != null) SimulatorPreviewStorage.show(e.getPlayer(), tntSimulator); - }, 10); } } @@ -103,29 +90,8 @@ public class TNTSimulatorListener implements Listener { public void onPlayerQuit(PlayerQuitEvent event) { SimulatorCursor.hide(event.getPlayer(), null); SimulatorStorage.getSimulatorNames().forEach(s -> { - SimulatorStorage.getSimulator(s).remove(event.getPlayer()); + SimulatorStorage.getSimulator(s).hide(event.getPlayer()); }); - SimulatorPreviewStorage.hide(event.getPlayer()); - } - - @EventHandler - public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { - TNTSimulator tntSimulator = SimulatorStorage.getSimulator(event.getOffHandItem()); - if (tntSimulator == null) { - SimulatorPreviewStorage.hide(event.getPlayer()); - return; - } - SimulatorPreviewStorage.show(event.getPlayer(), tntSimulator); - } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) { - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SimulatorPreviewStorage::recalculateAll, 1); - } - - @EventHandler - public void onBlockBreak(BlockBreakEvent event) { - Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), SimulatorPreviewStorage::recalculateAll, 1); } @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorSelectionGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorSelectionGUI.java index b442088a..2ca90d2a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorSelectionGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/SimulatorSelectionGUI.java @@ -49,7 +49,7 @@ public class SimulatorSelectionGUI { SWListInv inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("SIMULATOR_GUI_SELECT_SIM", player), false, swListEntryList, (clickType, tntSimulator) -> { TNTSimulator current = SimulatorStorage.getSimulator(hand); if (current != null) { - current.remove(player); + current.hide(player); } SimulatorStorage.setSimulator(player, hand, tntSimulator); player.getInventory().setItemInMainHand(hand); @@ -64,7 +64,7 @@ public class SimulatorSelectionGUI { if (SimulatorCommand.createSimulator(player, s)) { TNTSimulator current = SimulatorStorage.getSimulator(hand); if (current != null) { - current.remove(player); + current.hide(player); } TNTSimulator tntSimulator = SimulatorStorage.getSimulator(s); SimulatorStorage.setSimulator(player, hand, tntSimulator); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java index 24a1a3a7..aa849447 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTElementGUI.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.simulator.OrderUtils; -import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage; import de.steamwar.bausystem.features.simulator.SimulatorStorage; import de.steamwar.bausystem.features.simulator.TNTSimulator; import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial; @@ -42,7 +41,6 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique; @@ -66,7 +64,6 @@ public class TNTElementGUI { } TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); - AtomicBoolean recalculate = new AtomicBoolean(false); Runnable editObserver = () -> { List locationLore = new ArrayList<>(); locationLore.add(""); @@ -76,7 +73,6 @@ public class TNTElementGUI { inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_LOCATION", player), locationLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; editLocation(player, tntElement, () -> open(player, tntElement, back)); - recalculate.set(true); })); List propertiesLore = new ArrayList<>(); @@ -91,7 +87,6 @@ public class TNTElementGUI { inv.setItem(22, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_PROPERTIES", player), propertiesLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; editProperties(player, tntElement, () -> open(player, tntElement, back)); - recalculate.set(true); })); List otherLore = new ArrayList<>(); @@ -105,13 +100,11 @@ public class TNTElementGUI { inv.setItem(24, new SWItem(Material.ANVIL, BauSystem.MESSAGE.parse("SIMULATOR_EDIT_OTHER", player), otherLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; editOther(player, tntElement, () -> open(player, tntElement, back)); - recalculate.set(true); })); // Delete tnt inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.remove(tntElement); player.closeInventory(); })); @@ -120,9 +113,6 @@ public class TNTElementGUI { tntElement.register(editObserver, player::closeInventory); inv.addCloseRunnable(() -> { tntElement.unregister(editObserver); - if (recalculate.get()) { - SimulatorPreviewStorage.recalculate(tntSimulator); - } }); inv.open(); @@ -135,14 +125,12 @@ public class TNTElementGUI { } TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); - AtomicBoolean recalculate = new AtomicBoolean(false); Runnable editObserver = () -> { - ChangePosition.show(inv, player, recalculate, tntSimulator, tntElement, tntElement::getOwnPosition, x -> x - tntElement.getParentPosition().getX(), y -> y - tntElement.getParentPosition().getY(), z -> z - tntElement.getParentPosition().getZ(), () -> editLocation(player, tntElement, back)); + 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(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_Z", player), clickType -> { // Z negative if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.hide(tntElement); Vector position = tntElement.getPosition(); align(position, new Vector(0, 0, 0.49)); @@ -152,7 +140,6 @@ public class TNTElementGUI { })); inv.setItem(25, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_Z", player), clickType -> { // Z positive if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.hide(tntElement); Vector position = tntElement.getPosition(); align(position, new Vector(0, 0, 0.51)); @@ -162,7 +149,6 @@ public class TNTElementGUI { })); inv.setItem(15, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_POSITIVE_X", player), clickType -> { // X positive if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.hide(tntElement); Vector position = tntElement.getPosition(); align(position, new Vector(0.51, 0, 0)); @@ -172,7 +158,6 @@ public class TNTElementGUI { })); inv.setItem(33, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_NEGATIVE_X", player), clickType -> { // X negative if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.hide(tntElement); Vector position = tntElement.getPosition(); align(position, new Vector(0.49, 0, 0)); @@ -182,7 +167,6 @@ public class TNTElementGUI { })); inv.setItem(24, new SWItem(Material.SUNFLOWER, BauSystem.MESSAGE.parse("SIMULATOR_ALIGNMENT_CENTER", player), clickType -> { // CENTER if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.hide(tntElement); Vector position = tntElement.getPosition(); align(position, new Vector(0.5, 0, 0.5)); @@ -196,9 +180,6 @@ public class TNTElementGUI { tntElement.register(editObserver, player::closeInventory); inv.addCloseRunnable(() -> { tntElement.unregister(editObserver); - if (recalculate.get()) { - SimulatorPreviewStorage.recalculate(tntSimulator); - } }); inv.open(); @@ -236,18 +217,15 @@ public class TNTElementGUI { List lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player)); TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); - AtomicBoolean recalculate = new AtomicBoolean(false); Runnable editObserver = () -> { // Change Count of spawned TNT inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setCount(tntElement.getCount() + ((clickType.isShiftClick()) ? 5 : 1)); tntElement.change(); }))); SWItem countItem = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT", player, tntElement.getCount()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_COUNT_ANVIL_GUI_NAME", player), tntElement.getCount(), c -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setCount(c); tntElement.change(); editProperties(player, tntElement, back); @@ -256,7 +234,6 @@ public class TNTElementGUI { inv.setItem(19, countItem); inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setCount(tntElement.getCount() - ((clickType.isShiftClick()) ? 5 : 1)); tntElement.change(); }))); @@ -264,13 +241,11 @@ public class TNTElementGUI { // Change TickOffset inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setTickOffset(tntElement.getOwnTickOffset() + (clickType.isShiftClick() ? 5 : 1)); tntElement.change(); }))); SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntElement.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntElement.getTickOffset(), tick -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setTickOffset(tick - tntElement.getParentTickOffset()); tntElement.change(); editProperties(player, tntElement, back); @@ -279,7 +254,6 @@ public class TNTElementGUI { inv.setItem(20, tickItem); inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setTickOffset(tntElement.getOwnTickOffset() - (clickType.isShiftClick() ? 5 : 1)); tntElement.change(); }))); @@ -287,13 +261,11 @@ public class TNTElementGUI { // Change FuseTicks inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setFuseTicks(tntElement.getFuseTicks() + (clickType.isShiftClick() ? 5 : 1)); tntElement.change(); }))); SWItem fuseTickItem = new SWItem(Material.CLOCK, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE", player, tntElement.getFuseTicks()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_FUSE_ANVIL_GUI_NAME", player), tntElement.getFuseTicks(), tick -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setFuseTicks(tick); tntElement.change(); editProperties(player, tntElement, back); @@ -302,7 +274,6 @@ public class TNTElementGUI { inv.setItem(21, fuseTickItem); inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setFuseTicks(tntElement.getFuseTicks() - (clickType.isShiftClick() ? 5 : 1)); tntElement.change(); }))); @@ -310,7 +281,6 @@ public class TNTElementGUI { // Velocity Settings inv.setItem(24, Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_NAME", player), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntElement.isXVelocity() || tntElement.isYVelocity() || tntElement.isZVelocity()) { tntElement.setXVelocity(false); tntElement.setYVelocity(false); @@ -324,19 +294,16 @@ public class TNTElementGUI { }); inv.setItem(32, new SWItem(getWool(tntElement.isXVelocity()), getColor(tntElement.isXVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_X", player, active(player, tntElement.isXVelocity())), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setXVelocity(!tntElement.isXVelocity()); tntElement.change(); })); inv.setItem(15, new SWItem(getWool(tntElement.isYVelocity()), getColor(tntElement.isYVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Y", player, active(player, tntElement.isYVelocity())), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setYVelocity(!tntElement.isYVelocity()); tntElement.change(); })); inv.setItem(34, new SWItem(getWool(tntElement.isZVelocity()), getColor(tntElement.isZVelocity()), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_VELOCITY_Z", player, active(player, tntElement.isZVelocity())), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntElement.setZVelocity(!tntElement.isZVelocity()); tntElement.change(); })); @@ -345,9 +312,6 @@ public class TNTElementGUI { tntElement.register(editObserver, player::closeInventory); inv.addCloseRunnable(() -> { tntElement.unregister(editObserver); - if (recalculate.get()) { - SimulatorPreviewStorage.recalculate(tntSimulator); - } }); inv.open(); @@ -360,11 +324,9 @@ public class TNTElementGUI { } TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); - AtomicBoolean recalculate = new AtomicBoolean(false); Runnable editObserver = () -> { inv.setItem(19, new SWItem(tntElement.getOrder(), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ACTIVATED_NAME", player), OrderUtils.orderList(tntElement.getOrder(), player), false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (clickType.isShiftClick()) { tntElement.setOrder(OrderUtils.previous(tntElement.getOrder())); } else { @@ -374,12 +336,11 @@ public class TNTElementGUI { })); ChangeMaterial.show(inv, player, 21, tntElement, Material.BARREL, () -> editOther(player, tntElement, back)); - Disabled.show(inv, player, recalculate, 22, tntSimulator, tntElement); + Disabled.show(inv, player, 22, tntSimulator, tntElement); if (!tntElement.hasParent()) { inv.setItem(24, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_IGNITION_PHASE", player), Arrays.asList(), false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); // Create TNTGroup tntSimulator.getTntElementList().remove(tntElement); Vector vector = tntElement.getOwnPosition().clone(); @@ -409,7 +370,6 @@ public class TNTElementGUI { inv.setItem(25, new SWItem(Material.DISPENSER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_ADD_TNT", player), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); Vector vector = tntElement.getOwnPosition().clone(); TNTElement newElement = new TNTElement(vector); if (tntElement.hasParent()) { @@ -427,7 +387,6 @@ public class TNTElementGUI { // Delete tnt inv.setItem(44, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_REMOVE_TNT", player), clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntSimulator.remove(tntElement); player.closeInventory(); })); @@ -436,9 +395,6 @@ public class TNTElementGUI { tntElement.register(editObserver, player::closeInventory); inv.addCloseRunnable(() -> { tntElement.unregister(editObserver); - if (recalculate.get()) { - SimulatorPreviewStorage.recalculate(tntSimulator); - } }); inv.open(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTGroupEditGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTGroupEditGUI.java index 3f2cc7e8..7c53f610 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTGroupEditGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTGroupEditGUI.java @@ -20,7 +20,6 @@ package de.steamwar.bausystem.features.simulator.gui; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage; import de.steamwar.bausystem.features.simulator.SimulatorStorage; import de.steamwar.bausystem.features.simulator.TNTSimulator; import de.steamwar.bausystem.features.simulator.gui.components.ChangeMaterial; @@ -41,7 +40,6 @@ import org.bukkit.util.Vector; import java.util.Arrays; import java.util.List; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.UnaryOperator; import static de.steamwar.bausystem.features.simulator.gui.ItemUtils.unique; @@ -80,51 +78,39 @@ public class TNTGroupEditGUI { // X Position inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(simulatorElements, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR); - tntSimulator.show(); tntSimulator.change(); }))); inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, vector.getX()), lore, false, clickType -> {})); inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(simulatorElements, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1)); - tntSimulator.show(); tntSimulator.change(); }))); // Y Position inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(simulatorElements, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR); - tntSimulator.show(); tntSimulator.change(); }))); inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, vector.getY()), lore, false, clickType -> {})); inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(simulatorElements, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1)); - tntSimulator.show(); tntSimulator.change(); }))); // Z Position inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(simulatorElements, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR); - tntSimulator.show(); tntSimulator.change(); }))); inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, vector.getZ()), lore, false, clickType -> {})); inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(simulatorElements, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1)); - tntSimulator.show(); }))); inv.open(); @@ -161,22 +147,19 @@ public class TNTGroupEditGUI { List lore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_LORE", player)); TNTSimulator tntSimulator = SimulatorStorage.getSimulator(player); - AtomicBoolean recalculate = new AtomicBoolean(false); Runnable editObserver = () -> { - ChangePosition.show(inv, player, recalculate, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back)); + ChangePosition.show(inv, player, tntSimulator, tntGroup, tntGroup::getPosition, UnaryOperator.identity(), UnaryOperator.identity(), UnaryOperator.identity(), () -> open(player, tntGroup, back)); ChangeMaterial.show(inv, player, 14, tntGroup, Material.BARREL, () -> open(player, tntGroup, back)); - Disabled.show(inv, player, recalculate, 32, tntSimulator, tntGroup); + Disabled.show(inv, player, 32, tntSimulator, tntGroup); // Change TickOffset inv.setItem(16, new SWItem(SWItem.getDye(10), plusOneName, plusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntGroup.setTickOffset(tntGroup.getTickOffset() + (clickType.isShiftClick() ? 5 : 1)); tntGroup.change(); })); SWItem tickItem = new SWItem(SWItem.getMaterial("DIODE"), BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK", player, tntGroup.getTickOffset()), lore, false, clickType -> changeCount(player, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_TICK_ANVIL_GUI_NAME", player), tntGroup.getTickOffset(), tick -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntGroup.setTickOffset(tick); tntGroup.change(); open(player, tntGroup, back); @@ -185,7 +168,6 @@ public class TNTGroupEditGUI { inv.setItem(25, tickItem); inv.setItem(34, new SWItem(SWItem.getDye(1), minusOneName, minusOneFiveShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); tntGroup.setTickOffset(tntGroup.getTickOffset() - (clickType.isShiftClick() ? 5 : 1)); tntGroup.change(); })); @@ -194,7 +176,6 @@ public class TNTGroupEditGUI { tntGroup.register(editObserver, player::closeInventory); inv.addCloseRunnable(() -> { tntGroup.unregister(editObserver); - SimulatorPreviewStorage.recalculate(tntSimulator); }); inv.open(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java index d87b36d5..0030d2a4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/TNTSimulatorGui.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.simulator.gui; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.features.simulator.SimulatorPreviewStorage; import de.steamwar.bausystem.features.simulator.SimulatorStorage; import de.steamwar.bausystem.features.simulator.TNTSimulator; import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; @@ -117,7 +116,6 @@ public class TNTSimulatorGui { currentTntGroup.register(editObserver, player::closeInventory); inv.addCloseRunnable(() -> { currentTntGroup.unregister(editObserver); - SimulatorPreviewStorage.recalculate(currentTntSimulator); }); } else { if (!elements.isEmpty()) { @@ -126,15 +124,11 @@ public class TNTSimulatorGui { TNTGroupEditGUI.open(player, tntSimulator, elements, () -> open(player, currentTntSimulator, currentTntGroup, simulatorElements, back)); })); } - inv.addCloseCallback(clickType -> { - SimulatorPreviewStorage.recalculate(currentTntSimulator); - }); } if (currentTntSimulator != null || currentTntGroup != null) { inv.setItem(51, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("SIMULATOR_GUI_DELETE", player), clickType -> { if (currentTntSimulator != null) { - currentTntSimulator.hide(); currentTntSimulator.getTntElementList().forEach(SimulatorElement::close); currentTntSimulator.getTntElementList().clear(); player.closeInventory(); @@ -169,51 +163,40 @@ public class TNTSimulatorGui { // X Position inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(tntSimulator, clickType.isShiftClick() ? X_VECTOR : FX_VECTOR); - tntSimulator.show(); tntSimulator.change(); }))); inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_X", player), lore, false, clickType -> {})); inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(tntSimulator, (clickType.isShiftClick() ? X_VECTOR : FX_VECTOR).clone().multiply(-1)); - tntSimulator.show(); tntSimulator.change(); }))); // Y Position inv.setItem(13, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(tntSimulator, clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR); - tntSimulator.show(); tntSimulator.change(); }))); inv.setItem(22, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Y", player), lore, false, clickType -> {})); inv.setItem(31, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(tntSimulator, (clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR).clone().multiply(-1)); - tntSimulator.show(); tntSimulator.change(); }))); // Z Position inv.setItem(14, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(tntSimulator, clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR); - tntSimulator.show(); tntSimulator.change(); }))); inv.setItem(23, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_POSITION_Z", player), lore, false, clickType -> {})); inv.setItem(32, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - tntSimulator.hide(); moveAll(tntSimulator, (clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR).clone().multiply(-1)); - tntSimulator.show(); + tntSimulator.change(); }))); inv.open(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/ChangePosition.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/ChangePosition.java index 88b849d6..221ced49 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/ChangePosition.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/ChangePosition.java @@ -51,7 +51,7 @@ public class ChangePosition { private static final Vector FY_VECTOR = new Vector(0, 1, 0); private static final Vector FZ_VECTOR = new Vector(0, 0, 1); - public void show(SWInventory inv, Player player, AtomicBoolean recalculate, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier toChangeVector, UnaryOperator calculatePositionX, UnaryOperator calculatePositionY, UnaryOperator calculatePositionZ, Runnable back) { + public void show(SWInventory inv, Player player, TNTSimulator tntSimulator, SimulatorElement simulatorElement, Supplier toChangeVector, UnaryOperator calculatePositionX, UnaryOperator calculatePositionY, UnaryOperator calculatePositionZ, Runnable back) { String plusOneName = BauSystem.MESSAGE.parse("SIMULATOR_PLUS_ONE", player); String minusOneName = BauSystem.MESSAGE.parse("SIMULATOR_MINUS_ONE", player); List plusOnePixelShiftLore = Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_PLUS_PIXEL_SHIFT", player)); @@ -61,7 +61,6 @@ public class ChangePosition { // X Position inv.setItem(10, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().add(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -69,7 +68,6 @@ public class ChangePosition { }))); inv.setItem(19, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_X", player, simulatorElement.getPosition().getX()), lore, false, clickType -> { changePosition(player, simulatorElement.getPosition().getX(), x -> { - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().setX(clamp(calculatePositionX.apply(x))); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -79,7 +77,6 @@ public class ChangePosition { })); inv.setItem(28, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().subtract(clickType.isShiftClick() ? X_VECTOR : FX_VECTOR); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -89,7 +86,6 @@ public class ChangePosition { // Y Position inv.setItem(11, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().add(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -97,7 +93,6 @@ public class ChangePosition { }))); inv.setItem(20, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Y", player, simulatorElement.getPosition().getY()), lore, false, clickType -> { changePosition(player, simulatorElement.getPosition().getY(), y -> { - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().setY(clamp(calculatePositionY.apply(y))); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -107,7 +102,6 @@ public class ChangePosition { })); inv.setItem(29, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().subtract(clickType.isShiftClick() ? Y_VECTOR : FY_VECTOR); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -117,7 +111,6 @@ public class ChangePosition { // Z Position inv.setItem(12, unique(new SWItem(SWItem.getDye(10), plusOneName, plusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().add(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -125,7 +118,6 @@ public class ChangePosition { }))); inv.setItem(21, new SWItem(Material.PAPER, BauSystem.MESSAGE.parse("SIMULATOR_TNT_SPAWN_POSITION_Z", player, simulatorElement.getPosition().getZ()), lore, false, clickType -> { changePosition(player, simulatorElement.getPosition().getZ(), z -> { - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().setZ(clamp(calculatePositionZ.apply(z))); if (tntSimulator != null) tntSimulator.show(simulatorElement); @@ -135,7 +127,6 @@ public class ChangePosition { })); inv.setItem(30, unique(new SWItem(SWItem.getDye(1), minusOneName, minusOnePixelShiftLore, false, clickType -> { if (clickType == ClickType.DOUBLE_CLICK) return; - recalculate.set(true); if (tntSimulator != null) tntSimulator.hide(simulatorElement); toChangeVector.get().subtract(clickType.isShiftClick() ? Z_VECTOR : FZ_VECTOR); if (tntSimulator != null) tntSimulator.show(simulatorElement); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/Disabled.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/Disabled.java index dcb0b8bb..3ac98483 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/Disabled.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/gui/components/Disabled.java @@ -29,14 +29,12 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; @UtilityClass public class Disabled { - public void show(SWInventory inv, Player player, AtomicBoolean recalculate, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) { + public void show(SWInventory inv, Player player, int position, TNTSimulator tntSimulator, SimulatorElement simulatorElement) { inv.setItem(position, new SWItem(simulatorElement.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, BauSystem.MESSAGE.parse(simulatorElement.isDisabled() ? "SIMULATOR_TNT_SPAWN_DISABLED" : "SIMULATOR_TNT_SPAWN_ENABLED", player), new ArrayList<>(), !simulatorElement.isDisabled(), clickType -> { - recalculate.set(true); if (!simulatorElement.isDisabled()) { tntSimulator.hide(simulatorElement); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/SimulatorEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/SimulatorEntityShowMode.java deleted file mode 100644 index 8cdb228c..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/show/SimulatorEntityShowMode.java +++ /dev/null @@ -1,71 +0,0 @@ -package de.steamwar.bausystem.features.simulator.show; - -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; -import de.steamwar.bausystem.features.simulator.SimulatorStorage; -import de.steamwar.bausystem.shared.Position; -import de.steamwar.bausystem.shared.RoundedPosition; -import de.steamwar.bausystem.shared.ShowMode; -import de.steamwar.bausystem.utils.NMSWrapper; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.HashMap; -import java.util.Map; - -public class SimulatorEntityShowMode implements ShowMode { - - protected final Player player; - - private final Map entityMap = new HashMap<>(); - - public SimulatorEntityShowMode(Player player) { - this.player = player; - } - - @Override - public void show(Position position) { - RoundedPosition roundedPosition = new RoundedPosition(position); - AbstractSimulatorEntity entity = entityMap.computeIfAbsent(roundedPosition, pos -> createEntity(position.getLocation(), false)); - entity.display(player); - } - - public static AbstractSimulatorEntity createEntity(Vector position, boolean highlight) { - return NMSWrapper.impl.createSimulator(SimulatorStorage.WORLD, position, highlight); - } - - public void hide(Position position) { - RoundedPosition roundedPosition = new RoundedPosition(position); - AbstractSimulatorEntity abstractSimulatorEntity = entityMap.get(roundedPosition); - if (abstractSimulatorEntity == null) { - return; - } - if (abstractSimulatorEntity.hide(player, false)) { - entityMap.remove(roundedPosition); - } - } - - @Override - public void hide() { - entityMap.forEach((roundedPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true)); - entityMap.clear(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java index c4c48e4e..10ce5cd2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/SimulatorElement.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.features.simulator.tnt; -import de.steamwar.bausystem.features.simulator.SimulatorPreview; import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; @@ -51,7 +50,6 @@ public interface SimulatorElement { SWItem menu(Player p); boolean locations(Map>>> result, Region region, Location location); // Ticks to subtick order to spawning runnable to count of activations - void locations(Map>>> result); int tntCount(); int tick(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java index 29fcd778..7b2cc3f5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTElement.java @@ -32,6 +32,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Position; +import de.steamwar.entity.RFallingBlockEntity; import de.steamwar.inventory.SWItem; import lombok.Getter; import lombok.Setter; @@ -48,7 +49,7 @@ import java.util.*; @Getter public class TNTElement implements SimulatorElement { - private final AbstractSimulatorEntity entity; + private final RFallingBlockEntity entity; TNTGroup tntGroup = null; private final Vector position; @@ -199,17 +200,6 @@ public class TNTElement implements SimulatorElement { return false; } - @Override - public void locations(Map>>> result) { - if (disabled) return; - Location location = getPosition().toLocation(SimulatorStorage.WORLD); - result.computeIfAbsent(getTickOffset(), ignore -> new HashMap<>()) - .computeIfAbsent(OrderUtils.order(order), ignore -> new HashSet<>()) - .add(new Pair<>( - new SimulatorPreview.SimulatorPreviewTNTData(location.getX(), location.getY(), location.getZ(), fuseTicks, xVelocity, yVelocity, zVelocity), - count)); - } - @Override public int tntCount() { return disabled ? 0 : count; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java index 4b75fef4..30a69044 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/tnt/TNTGroup.java @@ -152,14 +152,6 @@ public class TNTGroup implements SimulatorElement { return false; } - @Override - public void locations(Map>>> result) { - if (disabled) return; - for (TNTElement element : elements) { - element.locations(result); - } - } - @Override public int tntCount() { if (disabled) return 0; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/shared/AbstractEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/shared/AbstractEntity.java deleted file mode 100644 index a187531b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/shared/AbstractEntity.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.shared; - -import org.bukkit.entity.Player; - -public interface AbstractEntity { - void sendEntity(Player player); - void sendEntityDestroy(Player player); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java index 7bec2cbb..cbd307cc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/RayTraceUtils.java @@ -92,6 +92,7 @@ public class RayTraceUtils { for (REntity entity: entityList) { if (!isOccluded(startPos.toVector(), direction, new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()))) continue; double distanceSq = new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()).distanceSquared(startPos.toVector()); + if (distanceSq > 100.0) continue; if (distanceSq < nearestDistanceSq) { nearestHitEntity = entity; nearestHitResult = new RRayTraceResult(new Vector(entity.getX(), entity.getY() + 0.5, entity.getZ()), null, null, entity);