From bdd995197a60f90a905f12319bd5dee7f34a21af Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 4 May 2023 01:48:58 +0800 Subject: [PATCH] Return to using arm swings to update entity yaw --- .../nms/v1_13_R2/util/PlayerlistTrackerEntry.java | 6 ++---- .../nms/v1_14_R1/util/PlayerlistTracker.java | 6 ++---- .../nms/v1_15_R1/util/PlayerlistTracker.java | 6 ++---- .../nms/v1_16_R3/util/PlayerlistTracker.java | 6 ++---- .../nms/v1_17_R1/util/PlayerlistTracker.java | 6 ++---- .../nms/v1_18_R2/util/PlayerlistTracker.java | 6 ++---- .../nms/v1_19_R3/util/CitizensEntityTracker.java | 11 +++-------- 7 files changed, 15 insertions(+), 32 deletions(-) diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java index 512642d05..de1a038cd 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/PlayerlistTrackerEntry.java @@ -22,7 +22,7 @@ import net.citizensnpcs.util.NMS; import net.minecraft.server.v1_13_R2.Entity; import net.minecraft.server.v1_13_R2.EntityPlayer; import net.minecraft.server.v1_13_R2.EntityTrackerEntry; -import net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook; +import net.minecraft.server.v1_13_R2.PacketPlayOutAnimation; public class PlayerlistTrackerEntry extends EntityTrackerEntry { private final Entity tracker; @@ -86,9 +86,7 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry { NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); lastUpdatedPlayer = null; Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new PacketPlayOutEntityLook(tracker.getId(), (byte) (tracker.yaw * 256.0F / 360.0F), - (byte) (tracker.pitch * 256.0F / 360.0F), tracker.onGround)); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new PacketPlayOutAnimation(tracker, 0)); }, 1); if (!Setting.DISABLE_TABLIST.asBoolean()) return; diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerlistTracker.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerlistTracker.java index 9137cf5e9..b2eaffa6e 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerlistTracker.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/PlayerlistTracker.java @@ -21,7 +21,7 @@ import net.citizensnpcs.util.NMS; import net.minecraft.server.v1_14_R1.Entity; import net.minecraft.server.v1_14_R1.EntityPlayer; import net.minecraft.server.v1_14_R1.EntityTrackerEntry; -import net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook; +import net.minecraft.server.v1_14_R1.PacketPlayOutAnimation; import net.minecraft.server.v1_14_R1.PlayerChunkMap; import net.minecraft.server.v1_14_R1.PlayerChunkMap.EntityTracker; @@ -86,9 +86,7 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker { final EntityPlayer entityplayer = lastUpdatedPlayer; NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new PacketPlayOutEntityLook(tracker.getId(), (byte) (tracker.yaw * 256.0F / 360.0F), - (byte) (tracker.pitch * 256.0F / 360.0F), tracker.onGround)); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new PacketPlayOutAnimation(tracker, 0)); }, 1); if (!Setting.DISABLE_TABLIST.asBoolean()) return; diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerlistTracker.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerlistTracker.java index 897b94889..2bf60fa93 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerlistTracker.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/PlayerlistTracker.java @@ -21,7 +21,7 @@ import net.citizensnpcs.util.NMS; import net.minecraft.server.v1_15_R1.Entity; import net.minecraft.server.v1_15_R1.EntityPlayer; import net.minecraft.server.v1_15_R1.EntityTrackerEntry; -import net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutEntityLook; +import net.minecraft.server.v1_15_R1.PacketPlayOutAnimation; import net.minecraft.server.v1_15_R1.PlayerChunkMap; import net.minecraft.server.v1_15_R1.PlayerChunkMap.EntityTracker; @@ -86,9 +86,7 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker { final EntityPlayer entityplayer = lastUpdatedPlayer; NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new PacketPlayOutEntityLook(tracker.getId(), (byte) (tracker.yaw * 256.0F / 360.0F), - (byte) (tracker.pitch * 256.0F / 360.0F), tracker.onGround)); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new PacketPlayOutAnimation(tracker, 0)); }, 1); if (!Setting.DISABLE_TABLIST.asBoolean()) return; diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerlistTracker.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerlistTracker.java index 48bd5ce1a..7f8687ea7 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerlistTracker.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/PlayerlistTracker.java @@ -21,7 +21,7 @@ import net.citizensnpcs.util.NMS; import net.minecraft.server.v1_16_R3.Entity; import net.minecraft.server.v1_16_R3.EntityPlayer; import net.minecraft.server.v1_16_R3.EntityTrackerEntry; -import net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook; +import net.minecraft.server.v1_16_R3.PacketPlayOutAnimation; import net.minecraft.server.v1_16_R3.PlayerChunkMap; import net.minecraft.server.v1_16_R3.PlayerChunkMap.EntityTracker; @@ -86,9 +86,7 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker { final EntityPlayer entityplayer = lastUpdatedPlayer; NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new PacketPlayOutEntityLook(tracker.getId(), (byte) (tracker.yaw * 256.0F / 360.0F), - (byte) (tracker.pitch * 256.0F / 360.0F), tracker.isOnGround())); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new PacketPlayOutAnimation(tracker, 0)); }, 1); if (!Setting.DISABLE_TABLIST.asBoolean()) return; diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerlistTracker.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerlistTracker.java index 39381bb70..34c2ec0d8 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerlistTracker.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/PlayerlistTracker.java @@ -13,7 +13,7 @@ import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; -import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap.TrackedEntity; import net.minecraft.server.level.ServerEntity; @@ -40,9 +40,7 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity { final ServerPlayer entityplayer = lastUpdatedPlayer; NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new ClientboundMoveEntityPacket.Rot(tracker.getId(), (byte) (tracker.getYRot() * 256.0F / 360.0F), - (byte) (tracker.getXRot() * 256.0F / 360.0F), tracker.isOnGround())); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)); }, 1); if (!Setting.DISABLE_TABLIST.asBoolean()) return; diff --git a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerlistTracker.java b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerlistTracker.java index 99809cf89..34f531ba1 100644 --- a/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerlistTracker.java +++ b/v1_18_R2/src/main/java/net/citizensnpcs/nms/v1_18_R2/util/PlayerlistTracker.java @@ -13,7 +13,7 @@ import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; -import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap.TrackedEntity; import net.minecraft.server.level.ServerEntity; @@ -40,9 +40,7 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity { final ServerPlayer entityplayer = lastUpdatedPlayer; NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new ClientboundMoveEntityPacket.Rot(tracker.getId(), (byte) (tracker.getYRot() * 256.0F / 360.0F), - (byte) (tracker.getXRot() * 256.0F / 360.0F), tracker.onGround)); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)); }, 1); if (!Setting.DISABLE_TABLIST.asBoolean()) return; diff --git a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CitizensEntityTracker.java b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CitizensEntityTracker.java index a540b346c..a95220f75 100644 --- a/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CitizensEntityTracker.java +++ b/v1_19_R3/src/main/java/net/citizensnpcs/nms/v1_19_R3/util/CitizensEntityTracker.java @@ -16,7 +16,7 @@ import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.nms.v1_19_R3.entity.EntityHumanNPC; import net.citizensnpcs.npc.ai.NPCHolder; import net.citizensnpcs.util.NMS; -import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket; +import net.minecraft.network.protocol.game.ClientboundAnimatePacket; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ChunkMap.TrackedEntity; import net.minecraft.server.level.ServerEntity; @@ -63,17 +63,12 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity { boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new ClientboundMoveEntityPacket.Rot(tracker.getId(), - (byte) (tracker.getYRot() * 256.0F / 360.0F), - (byte) (tracker.getXRot() * 256.0F / 360.0F), tracker.onGround)); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)); }, 1); return; } Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new ClientboundMoveEntityPacket.Rot(tracker.getId(), (byte) (tracker.getYRot() * 256.0F / 360.0F), - (byte) (tracker.getXRot() * 256.0F / 360.0F), tracker.onGround)); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)); NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); }, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks()); }