mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-13 19:52:05 +01:00
Send player look packets for older versions
This commit is contained in:
parent
8b1550dc43
commit
69b6509a0e
@ -18,6 +18,7 @@ import net.minecraft.server.v1_13_R2.Entity;
|
|||||||
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
import net.minecraft.server.v1_13_R2.EntityPlayer;
|
||||||
import net.minecraft.server.v1_13_R2.EntityTracker;
|
import net.minecraft.server.v1_13_R2.EntityTracker;
|
||||||
import net.minecraft.server.v1_13_R2.EntityTrackerEntry;
|
import net.minecraft.server.v1_13_R2.EntityTrackerEntry;
|
||||||
|
import net.minecraft.server.v1_13_R2.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
|
|
||||||
public class PlayerlistTrackerEntry extends EntityTrackerEntry {
|
public class PlayerlistTrackerEntry extends EntityTrackerEntry {
|
||||||
private EntityPlayer lastUpdatedPlayer;
|
private EntityPlayer lastUpdatedPlayer;
|
||||||
@ -42,6 +43,11 @@ public class PlayerlistTrackerEntry extends EntityTrackerEntry {
|
|||||||
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
lastUpdatedPlayer = null;
|
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));
|
||||||
|
}, 1);
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.util.NMS;
|
|||||||
import net.minecraft.server.v1_14_R1.Entity;
|
import net.minecraft.server.v1_14_R1.Entity;
|
||||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTrackerEntry;
|
import net.minecraft.server.v1_14_R1.EntityTrackerEntry;
|
||||||
|
import net.minecraft.server.v1_14_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerChunkMap;
|
import net.minecraft.server.v1_14_R1.PlayerChunkMap;
|
||||||
import net.minecraft.server.v1_14_R1.PlayerChunkMap.EntityTracker;
|
import net.minecraft.server.v1_14_R1.PlayerChunkMap.EntityTracker;
|
||||||
|
|
||||||
@ -37,6 +38,11 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
return;
|
return;
|
||||||
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
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));
|
||||||
|
}, 1);
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.util.NMS;
|
|||||||
import net.minecraft.server.v1_15_R1.Entity;
|
import net.minecraft.server.v1_15_R1.Entity;
|
||||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_15_R1.EntityTrackerEntry;
|
import net.minecraft.server.v1_15_R1.EntityTrackerEntry;
|
||||||
|
import net.minecraft.server.v1_15_R1.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
import net.minecraft.server.v1_15_R1.PlayerChunkMap;
|
import net.minecraft.server.v1_15_R1.PlayerChunkMap;
|
||||||
import net.minecraft.server.v1_15_R1.PlayerChunkMap.EntityTracker;
|
import net.minecraft.server.v1_15_R1.PlayerChunkMap.EntityTracker;
|
||||||
|
|
||||||
@ -37,6 +38,11 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
return;
|
return;
|
||||||
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
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));
|
||||||
|
}, 1);
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
|
@ -16,6 +16,7 @@ import net.citizensnpcs.util.NMS;
|
|||||||
import net.minecraft.server.v1_16_R3.Entity;
|
import net.minecraft.server.v1_16_R3.Entity;
|
||||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||||
import net.minecraft.server.v1_16_R3.EntityTrackerEntry;
|
import net.minecraft.server.v1_16_R3.EntityTrackerEntry;
|
||||||
|
import net.minecraft.server.v1_16_R3.PacketPlayOutEntity.PacketPlayOutEntityLook;
|
||||||
import net.minecraft.server.v1_16_R3.PlayerChunkMap;
|
import net.minecraft.server.v1_16_R3.PlayerChunkMap;
|
||||||
import net.minecraft.server.v1_16_R3.PlayerChunkMap.EntityTracker;
|
import net.minecraft.server.v1_16_R3.PlayerChunkMap.EntityTracker;
|
||||||
|
|
||||||
@ -37,6 +38,11 @@ public class PlayerlistTracker extends PlayerChunkMap.EntityTracker {
|
|||||||
return;
|
return;
|
||||||
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
final EntityPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
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()));
|
||||||
|
}, 1);
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
|
@ -13,6 +13,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC;
|
import net.citizensnpcs.nms.v1_17_R1.entity.EntityHumanNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
||||||
import net.minecraft.server.level.ServerEntity;
|
import net.minecraft.server.level.ServerEntity;
|
||||||
@ -38,14 +39,16 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
|||||||
return;
|
return;
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
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()));
|
||||||
|
}, 1);
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
@Override
|
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
||||||
public void run() {
|
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
|
||||||
}
|
|
||||||
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,7 @@ import net.citizensnpcs.api.npc.NPC;
|
|||||||
import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC;
|
import net.citizensnpcs.nms.v1_18_R2.entity.EntityHumanNPC;
|
||||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||||
import net.citizensnpcs.util.NMS;
|
import net.citizensnpcs.util.NMS;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||||
import net.minecraft.server.level.ChunkMap;
|
import net.minecraft.server.level.ChunkMap;
|
||||||
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
import net.minecraft.server.level.ChunkMap.TrackedEntity;
|
||||||
import net.minecraft.server.level.ServerEntity;
|
import net.minecraft.server.level.ServerEntity;
|
||||||
@ -38,11 +39,16 @@ public class PlayerlistTracker extends ChunkMap.TrackedEntity {
|
|||||||
return;
|
return;
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
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));
|
||||||
|
}, 1);
|
||||||
if (!Setting.DISABLE_TABLIST.asBoolean())
|
if (!Setting.DISABLE_TABLIST.asBoolean())
|
||||||
return;
|
return;
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||||
() -> NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity()),
|
NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
}, Setting.TABLIST_REMOVE_PACKET_DELAY.asTicks());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1355,34 +1355,7 @@ public class NMSImpl implements NMSBridge {
|
|||||||
@Override
|
@Override
|
||||||
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
public void sendPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw, Float pitch,
|
||||||
Float headYaw) {
|
Float headYaw) {
|
||||||
Entity handle = getHandle(from);
|
List<Packet<?>> toSend = getPositionUpdate(from, position, bodyYaw, pitch, headYaw);
|
||||||
if (bodyYaw == null) {
|
|
||||||
bodyYaw = handle.getYRot();
|
|
||||||
}
|
|
||||||
if (pitch == null) {
|
|
||||||
pitch = handle.getXRot();
|
|
||||||
}
|
|
||||||
List<Packet<?>> toSend = Lists.newArrayList();
|
|
||||||
if (position) {
|
|
||||||
TrackedEntity entry = ((ServerLevel) handle.level).getChunkSource().chunkMap.entityMap.get(handle.getId());
|
|
||||||
VecDeltaCodec vdc = null;
|
|
||||||
try {
|
|
||||||
vdc = (VecDeltaCodec) POSITION_CODEC_GETTER.invoke((ServerEntity) SERVER_ENTITY_GETTER.invoke(entry));
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Vec3 pos = handle.trackingPosition();
|
|
||||||
toSend.add(new ClientboundMoveEntityPacket.PosRot(handle.getId(), (short) vdc.encodeX(pos),
|
|
||||||
(short) vdc.encodeY(pos), (short) vdc.encodeZ(pos), (byte) (bodyYaw * 256.0F / 360.0F),
|
|
||||||
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
|
||||||
} else {
|
|
||||||
toSend.add(new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
|
||||||
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
|
||||||
}
|
|
||||||
if (headYaw != null) {
|
|
||||||
toSend.add(new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
|
||||||
}
|
|
||||||
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
sendPacketsNearby(null, from.getLocation(), toSend, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2228,6 +2201,39 @@ public class NMSImpl implements NMSBridge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Packet<?>> getPositionUpdate(org.bukkit.entity.Entity from, boolean position, Float bodyYaw,
|
||||||
|
Float pitch, Float headYaw) {
|
||||||
|
Entity handle = getHandle(from);
|
||||||
|
if (bodyYaw == null) {
|
||||||
|
bodyYaw = handle.getYRot();
|
||||||
|
}
|
||||||
|
if (pitch == null) {
|
||||||
|
pitch = handle.getXRot();
|
||||||
|
}
|
||||||
|
List<Packet<?>> toSend = Lists.newArrayList();
|
||||||
|
if (position) {
|
||||||
|
TrackedEntity entry = ((ServerLevel) handle.level).getChunkSource().chunkMap.entityMap.get(handle.getId());
|
||||||
|
VecDeltaCodec vdc = null;
|
||||||
|
try {
|
||||||
|
vdc = (VecDeltaCodec) POSITION_CODEC_GETTER.invoke((ServerEntity) SERVER_ENTITY_GETTER.invoke(entry));
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
Vec3 pos = handle.trackingPosition();
|
||||||
|
toSend.add(new ClientboundMoveEntityPacket.PosRot(handle.getId(), (short) vdc.encodeX(pos),
|
||||||
|
(short) vdc.encodeY(pos), (short) vdc.encodeZ(pos), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
} else {
|
||||||
|
toSend.add(new ClientboundMoveEntityPacket.Rot(handle.getId(), (byte) (bodyYaw * 256.0F / 360.0F),
|
||||||
|
(byte) (pitch * 256.0F / 360.0F), handle.onGround));
|
||||||
|
}
|
||||||
|
if (headYaw != null) {
|
||||||
|
toSend.add(new ClientboundRotateHeadPacket(handle, (byte) (headYaw * 256.0F / 360.0F)));
|
||||||
|
}
|
||||||
|
return toSend;
|
||||||
|
}
|
||||||
|
|
||||||
public static EntityDataAccessor<Integer> getRabbitTypeField() {
|
public static EntityDataAccessor<Integer> getRabbitTypeField() {
|
||||||
return RABBIT_TYPE_DATAWATCHER;
|
return RABBIT_TYPE_DATAWATCHER;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user