Send rel look for 1.15 head rotation packet

This commit is contained in:
libraryaddict 2020-03-02 12:54:05 +13:00
parent f28e520b09
commit 7c89c9ca50
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -24,30 +24,32 @@ public class PacketHandlerHeadRotation implements IPacketHandler {
@Override
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
Entity entity) {
if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) {
Location loc = entity.getLocation();
byte pitch = DisguiseUtilities
.getPitch(disguise.getType(), entity.getType(), (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
byte yaw = DisguiseUtilities.getYaw(disguise.getType(), entity.getType(), sentPacket.getBytes().read(0));
PacketContainer rotation = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
StructureModifier<Object> mods = rotation.getModifier();
mods.write(0, entity.getEntityId());
mods.write(1, yaw);
PacketContainer look = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
look.getIntegers().write(0, entity.getEntityId());
look.getBytes().write(0, yaw);
look.getBytes().write(1, pitch);
packets.clear();
packets.addPacket(look);
packets.addPacket(rotation);
if (!disguise.getType().isPlayer() || entity.getType() == EntityType.PLAYER) {
return;
}
Location loc = entity.getLocation();
byte pitch = DisguiseUtilities
.getPitch(disguise.getType(), entity.getType(), (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
byte yaw = DisguiseUtilities.getYaw(disguise.getType(), entity.getType(), sentPacket.getBytes().read(0));
PacketContainer rotation = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
StructureModifier<Object> mods = rotation.getModifier();
mods.write(0, entity.getEntityId());
mods.write(1, yaw);
PacketContainer look = new PacketContainer(PacketType.Play.Server.REL_ENTITY_MOVE_LOOK);
look.getIntegers().write(0, entity.getEntityId());
look.getBytes().write(0, yaw);
look.getBytes().write(1, pitch);
packets.clear();
packets.addPacket(look);
packets.addPacket(rotation);
}
}