From 9f0f11adebf68c802c1a3a7348d4e8380dfbb840 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Thu, 2 Jan 2025 17:24:37 +0100 Subject: [PATCH] Fix entity orientation --- .../src/de/steamwar/core/BountifulWrapper21.java | 2 +- .../src/de/steamwar/core/BountifulWrapper8.java | 7 +++---- .../src/de/steamwar/core/BountifulWrapper9.java | 14 +++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java index d144c9b6..f7ed9508 100644 --- a/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java +++ b/SpigotCore/SpigotCore_21/src/de/steamwar/core/BountifulWrapper21.java @@ -33,7 +33,7 @@ public class BountifulWrapper21 extends BountifulWrapper9 { 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)); + field.set(packet, new PositionMoveRotation(new Vec3D(x, y, z), pos.b(), yaw, pitch)); }; } catch (IllegalArgumentException e) { return super.getPositionSetter(packetClass, fieldOffset); diff --git a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java index 54ea45b3..2b7aeab7 100644 --- a/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java +++ b/SpigotCore/SpigotCore_8/src/de/steamwar/core/BountifulWrapper8.java @@ -25,7 +25,6 @@ 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; @@ -71,15 +70,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); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, byte.class, 0); + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, byte.class, 1); 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)); + 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 fa126698..300d6c8d 100644 --- a/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java +++ b/SpigotCore/SpigotCore_9/src/de/steamwar/core/BountifulWrapper9.java @@ -67,19 +67,19 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { Reflection.FieldAccessor posZ = Reflection.getField(packetClass, double.class, fieldOffset+2); boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport") || packetClass.getSimpleName().contains("PacketPlayOutNamedEntitySpawn"); 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); + Reflection.FieldAccessor lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1); + Reflection.FieldAccessor lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2); return (packet, x, y, z, pitch, yaw) -> { posX.set(packet, x); posY.set(packet, y); posZ.set(packet, z); if (isByteClass) { - lookPitch.set(packet, (byte) (pitch*256/360)); lookYaw.set(packet, (byte) (yaw*256/360)); + lookPitch.set(packet, (byte) (pitch*256/360)); } else { - lookPitch.set(packet, (int) (pitch*256/360)); lookYaw.set(packet, (int) (yaw*256/360)); + lookPitch.set(packet, (int) (pitch*256/360)); } }; } @@ -90,15 +90,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); + Reflection.FieldAccessor moveYaw = Reflection.getField(packetClass, "e", byte.class); + Reflection.FieldAccessor movePitch = Reflection.getField(packetClass, "f", byte.class); 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)); + movePitch.set(packet, (byte)(pitch*256/360)); }; }