Tweak entity head yaw code

This commit is contained in:
fullwall 2023-07-27 19:02:44 +08:00
parent 71ad607732
commit 831cb4a5d8
2 changed files with 9 additions and 4 deletions

View File

@ -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);
}
}

View File

@ -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());
}