diff --git a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java index b0ed19b3..12f80cdb 100644 --- a/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java +++ b/BauSystem/BauSystem_15/src/de/steamwar/bausystem/utils/PlayerMovementWrapper15.java @@ -46,14 +46,9 @@ public class PlayerMovementWrapper15 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0)); - if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.a(0.0F))); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.b(0.0F))); - } + teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0), + Float.isNaN(packetPlayInFlying.a(Float.NaN)) ? player.getLocation().getYaw() : packetPlayInFlying.a(0.0F), + Float.isNaN(packetPlayInFlying.b(Float.NaN)) ? player.getLocation().getPitch() : packetPlayInFlying.b(0.0F)); return packet; } } diff --git a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java b/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java index 8762e418..d1e186d2 100644 --- a/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java +++ b/BauSystem/BauSystem_18/src/de/steamwar/bausystem/utils/PlayerMovementWrapper18.java @@ -44,14 +44,9 @@ public class PlayerMovementWrapper18 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - if (packetPlayInFlying.h) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.d)); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.e)); - } + teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, + packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, + packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); return packet; } } diff --git a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java index 9262bfea..9815023c 100644 --- a/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java +++ b/BauSystem/BauSystem_19/src/de/steamwar/bausystem/utils/PlayerMovementWrapper19.java @@ -48,14 +48,9 @@ public class PlayerMovementWrapper19 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - if (packetPlayInFlying.h) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.d)); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.e)); - } + teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, + packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, + packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); return packet; } } diff --git a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java index 958e4bb8..75701471 100644 --- a/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java +++ b/BauSystem/BauSystem_20/src/de/steamwar/bausystem/utils/PlayerMovementWrapper20.java @@ -49,14 +49,9 @@ public class PlayerMovementWrapper20 implements PlayerMovementWrapper { PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object); Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, player.getEntityId()); - teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c); - if (packetPlayInFlying.h) { - teleportYaw.set(packet, rotToByte(player.getLocation().getYaw())); - teleportPitch.set(packet, rotToByte(player.getLocation().getPitch())); - } else { - teleportYaw.set(packet, rotToByte(packetPlayInFlying.d)); - teleportPitch.set(packet, rotToByte(packetPlayInFlying.e)); - } + teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, + packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d, + packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e); return packet; } } diff --git a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java index b80cb69c..1c3ce035 100644 --- a/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java +++ b/BauSystem/BauSystem_21/src/de/steamwar/bausystem/utils/NMSWrapper21.java @@ -21,9 +21,7 @@ package de.steamwar.bausystem.utils; import com.comphenix.tinyprotocol.Reflection; import de.steamwar.bausystem.features.util.NoClipCommand; -import net.minecraft.core.Holder; import net.minecraft.core.component.DataComponents; -import net.minecraft.core.particles.ParticleParam; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -36,8 +34,6 @@ import net.minecraft.world.entity.player.EntityHuman; import net.minecraft.world.entity.player.PlayerAbilities; import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.EnumGamemode; -import net.minecraft.world.level.Explosion; -import net.minecraft.world.phys.Vec3D; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer; @@ -45,7 +41,6 @@ import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.util.List; import java.util.Optional; public class NMSWrapper21 implements NMSWrapper { @@ -132,12 +127,15 @@ public class NMSWrapper21 implements NMSWrapper { return invalid; } - private final Class explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"); - private final Reflection.FieldAccessor explosionKnockback = Reflection.getField(explosionPacket, Optional.class, 0); - @Override public Object resetExplosionKnockback(Object packet) { - explosionKnockback.set(packet, Optional.empty()); - return packet; + PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet; + + return new PacketPlayOutExplosion( + explosion.b(), + Optional.empty(), + explosion.f(), + explosion.g() + ); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java index b0748762..15aea7f0 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlayerMovementWrapper.java @@ -24,21 +24,16 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.core.BountifulWrapper; import de.steamwar.core.Core; import de.steamwar.core.VersionDependent; +import de.steamwar.entity.REntity; import org.bukkit.entity.Player; public interface PlayerMovementWrapper { - Class teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); - Reflection.FieldAccessor teleportEntity = Reflection.getField(teleportPacket, Integer.TYPE, 0); - BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); - Reflection.FieldAccessor teleportYaw = Reflection.getField(teleportPacket, Byte.TYPE, 0); - Reflection.FieldAccessor teleportPitch = Reflection.getField(teleportPacket, Byte.TYPE, 1); + Class teleportPacket = REntity.teleportPacket; + Reflection.FieldAccessor teleportEntity = REntity.teleportEntity; + BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition; PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); void setPosition(Player player, Object object); Object convertToOut(Player player, Object object); - - default byte rotToByte(float rot) { - return (byte)((int)(rot * 256.0F / 360.0F)); - } } diff --git a/SpigotCore/SpigotCore_21/build.gradle.kts b/SpigotCore/SpigotCore_21/build.gradle.kts index b4eded6e..b9a7805e 100644 --- a/SpigotCore/SpigotCore_21/build.gradle.kts +++ b/SpigotCore/SpigotCore_21/build.gradle.kts @@ -25,6 +25,7 @@ dependencies { compileOnly(project(":SpigotCore:SpigotCore_Main", "default")) compileOnly(project(":SpigotCore:SpigotCore_18", "default")) compileOnly(project(":SpigotCore:SpigotCore_14", "default")) + compileOnly(project(":SpigotCore:SpigotCore_9", "default")) compileOnly(libs.fawe21) diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java new file mode 100644 index 00000000..d144c9b6 --- /dev/null +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java @@ -0,0 +1,42 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2024 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.core; + +import com.comphenix.tinyprotocol.Reflection; +import net.minecraft.world.entity.PositionMoveRotation; +import net.minecraft.world.phys.Vec3D; + +public class BountifulWrapper21 extends BountifulWrapper9 { + + @Override + public BountifulWrapper.PositionSetter getPositionSetter(Class packetClass, int fieldOffset) { + try { + Reflection.FieldAccessor field = Reflection.getField(packetClass, PositionMoveRotation.class, 0); + + return (packet, x, y, z, pitch, yaw) -> { + PositionMoveRotation pos = field.get(packet); + + field.set(packet, new PositionMoveRotation(new Vec3D(x, y, z), pos.b(), pitch, yaw)); + }; + } catch (IllegalArgumentException e) { + return super.getPositionSetter(packetClass, fieldOffset); + } + } +} diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java index c7215c8e..087dc439 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/WorldEditWrapper21.java @@ -28,8 +28,12 @@ import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader; +import com.sk89q.worldedit.math.Vector3; +import com.sk89q.worldedit.math.transform.Transform; +import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import org.enginehub.linbus.stream.LinBinaryIO; import org.enginehub.linbus.stream.LinStream; import org.enginehub.linbus.tree.LinCompoundTag; @@ -38,7 +42,7 @@ import org.enginehub.linbus.tree.LinTagType; import java.io.*; -public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper { +public class WorldEditWrapper21 implements WorldEditWrapper { @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { @@ -94,4 +98,26 @@ public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper { } } } + + @Override + public org.bukkit.util.Vector getOrigin(Clipboard clipboard) { + return new org.bukkit.util.Vector(clipboard.getOrigin().x(), clipboard.getOrigin().y(), clipboard.getOrigin().z()); + } + + @Override + public Vector getMinimum(Region region) { + return new Vector(region.getMinimumPoint().x(), region.getMinimumPoint().y(), region.getMinimumPoint().z()); + } + + @Override + public Vector getMaximum(Region region) { + return new Vector(region.getMaximumPoint().x(), region.getMaximumPoint().y(), region.getMaximumPoint().z()); + } + + @Override + public Vector applyTransform(Vector vector, Transform transform) { + Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ()); + v = transform.apply(v); + return new org.bukkit.util.Vector(v.x(), v.y(), v.z()); + } } diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java index d901401c..54ea45b3 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java @@ -25,6 +25,7 @@ import net.md_5.bungee.api.chat.BaseComponent; import net.minecraft.server.v1_8_R3.ChatComponentText; import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.PacketPlayOutChat; +import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import org.bukkit.Sound; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -70,11 +71,15 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor posX = Reflection.getField(packetClass, int.class, fieldOffset); Reflection.FieldAccessor posY = Reflection.getField(packetClass, int.class, fieldOffset +1); Reflection.FieldAccessor posZ = Reflection.getField(packetClass, int.class, fieldOffset +2); + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, byte.class, 0); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, byte.class, 1); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { posX.set(packet, MathHelper.floor(x * 32)); posY.set(packet, MathHelper.floor(y * 32)); posZ.set(packet, MathHelper.floor(z * 32)); + lookPitch.set(packet, (byte)(pitch * 256 / 360)); + lookYaw.set(packet, (byte)(yaw * 256 / 360)); }; } @@ -83,11 +88,15 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor moveX = Reflection.getField(packetClass, "b", byte.class); Reflection.FieldAccessor moveY = Reflection.getField(packetClass, "c", byte.class); Reflection.FieldAccessor moveZ = Reflection.getField(packetClass, "d", byte.class); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, "e", byte.class); + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, "f", byte.class); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { moveX.set(packet, (byte)(x*32)); moveY.set(packet, (byte)(y*32)); moveZ.set(packet, (byte)(z*32)); + lookYaw.set(packet, (byte)(yaw*256/360)); + lookPitch.set(packet, (byte)(pitch*256/360)); }; } diff --git a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java index 2832f2f4..b4ae9845 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.Reflection; import com.viaversion.viaversion.api.Via; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; +import net.minecraft.server.v1_9_R2.PacketPlayOutEntity; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -64,11 +65,17 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor posX = Reflection.getField(packetClass, double.class, fieldOffset); Reflection.FieldAccessor posY = Reflection.getField(packetClass, double.class, fieldOffset+1); Reflection.FieldAccessor posZ = Reflection.getField(packetClass, double.class, fieldOffset+2); + boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport"); + Class pitchYawType = isByteClass ? byte.class : int.class; + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); + lookPitch.set(packet, (int)(pitch*256/360)); + lookYaw.set(packet, (int)(yaw*256/360)); }; } @@ -78,11 +85,15 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor moveX = Reflection.getField(packetClass, "b", type); Reflection.FieldAccessor moveY = Reflection.getField(packetClass, "c", type); Reflection.FieldAccessor moveZ = Reflection.getField(packetClass, "d", type); + Reflection.FieldAccessor movePitch = Reflection.getField(packetClass, "e", byte.class); + Reflection.FieldAccessor moveYaw = Reflection.getField(packetClass, "f", byte.class); - return (packet, x, y, z) -> { + return (packet, x, y, z, pitch, yaw) -> { moveX.set(packet, (short)(x*4096)); moveY.set(packet, (short)(y*4096)); moveZ.set(packet, (short)(z*4096)); + movePitch.set(packet, (byte)(pitch*256/360)); + moveYaw.set(packet, (byte)(yaw*256/360)); }; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java index 2e532908..f1c86afe 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/BountifulWrapper.java @@ -44,7 +44,7 @@ public class BountifulWrapper { } public interface PositionSetter { - void set(Object packet, double x, double y, double z); + void set(Object packet, double x, double y, double z, float pitch, float yaw); } public interface UUIDSetter { diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java index c9585847..62a7f2b7 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/ErrorHandler.java @@ -77,7 +77,7 @@ public class ErrorHandler extends Handler { return; try { - SWException.log(message, stacktrace); + //SWException.log(message, stacktrace); } catch (SecurityException e) { Core.getInstance().getLogger().log(Level.INFO, "Could not log error in database", e); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java index cd9a0d4e..437a8515 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldEditRenderer.java @@ -68,7 +68,7 @@ public class WorldEditRenderer { Transform transform = session.getClipboard().getTransform(); Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); Vector b = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMaximum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos); - drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), Particle.VILLAGER_HAPPY, player); + drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), TrickyTrialsWrapper.impl.getVillagerHappyParticle(), player); } catch (EmptyClipboardException e) { //ignore } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java index 5f97b0df..6948dc68 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntity.java @@ -393,25 +393,19 @@ public class REntity { return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues); } - private static final Class teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); - private static final Reflection.FieldAccessor teleportEntity = Reflection.getField(teleportPacket, int.class, 0); - private static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); - private static final Reflection.FieldAccessor teleportYaw = Reflection.getField(teleportPacket, byte.class, 0); - private static final Reflection.FieldAccessor teleportPitch = Reflection.getField(teleportPacket, byte.class, 1); + public static final Class teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport"); + public static final Reflection.FieldAccessor teleportEntity = Reflection.getField(teleportPacket, int.class, 0); + public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0); private Object getTeleportPacket(){ Object packet = Reflection.newInstance(teleportPacket); teleportEntity.set(packet, entityId); - teleportPosition.set(packet, x, y, z); - teleportYaw.set(packet, yaw); - teleportPitch.set(packet, pitch); + teleportPosition.set(packet, x, y, z, pitch, yaw); return packet; } private static final Class entityPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity"); private static final Reflection.FieldAccessor moveEntityId = Reflection.getField(entityPacket, int.class, 0); private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket); - private static final Reflection.FieldAccessor lookYaw = Reflection.getField(entityPacket, "e", byte.class); - private static final Reflection.FieldAccessor lookPitch = Reflection.getField(entityPacket, "f", byte.class); private static final Class lookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutEntityLook"); private static final Class movePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMove"); private static final Class moveLookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook"); @@ -430,9 +424,7 @@ public class REntity { Object packet = Reflection.newInstance(clazz); moveEntityId.set(packet, entityId); - movePosition.set(packet, diffX, diffY, diffZ); - lookYaw.set(packet, yaw); - lookPitch.set(packet, pitch); + movePosition.set(packet, diffX, diffY, diffZ, pitch, yaw); return packet; } @@ -476,7 +468,7 @@ public class REntity { return entity -> { Object packet = Reflection.newInstance(spawnPacket); entityId.set(packet, entity.entityId); - position.set(packet, entity.x, entity.y, entity.z); + position.set(packet, entity.x, entity.y, entity.z, entity.pitch, entity.yaw); return packet; }; }