From 831cb4a5d89a123f76401f609c30309b28607c38 Mon Sep 17 00:00:00 2001 From: fullwall Date: Thu, 27 Jul 2023 19:02:44 +0800 Subject: [PATCH] Tweak entity head yaw code --- .../nms/v1_20_R1/entity/EnderDragonController.java | 1 - .../nms/v1_20_R1/util/CitizensEntityTracker.java | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/entity/EnderDragonController.java b/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/entity/EnderDragonController.java index 2f620045a..149ef3f20 100644 --- a/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/entity/EnderDragonController.java +++ b/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/entity/EnderDragonController.java @@ -282,7 +282,6 @@ public class EnderDragonController extends MobEntityController { } private static final MethodHandle HURT = NMS.getMethodHandle(EnderDragon.class, "c", true, List.class); - private static final MethodHandle KNOCKBACK = NMS.getMethodHandle(EnderDragon.class, "b", true, List.class); } } diff --git a/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/util/CitizensEntityTracker.java b/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/util/CitizensEntityTracker.java index 30da21b21..cf7a9a4dc 100644 --- a/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/util/CitizensEntityTracker.java +++ b/v1_20_R1/src/main/java/net/citizensnpcs/nms/v1_20_R1/util/CitizensEntityTracker.java @@ -62,6 +62,12 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity { if (tracker.isRemoved() || tracker.getBukkitEntity().getType() != EntityType.PLAYER) return; final ServerPlayer entityplayer = lastUpdatedPlayer; + Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { + if (tracker.isRemoved() || entityplayer.isRemoved()) + return; + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), + new ClientboundRotateHeadPacket(tracker, (byte) (tracker.getYHeadRot() * 256.0F / 360.0F))); + }, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks() + 1); boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) { Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), @@ -70,10 +76,10 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity { return; } Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> { - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), - new ClientboundRotateHeadPacket(tracker, (byte) (tracker.getYHeadRot() * 256.0F / 360.0F))); - NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)); + if (tracker.isRemoved() || entityplayer.isRemoved()) + return; NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()); + NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)); }, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks()); }