Return to using arm swings to update entity yaw

This commit is contained in:
fullwall 2023-05-04 01:48:58 +08:00
parent 0b076b1a21
commit bdd995197a
7 changed files with 15 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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