mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-11-05 09:09:40 +01:00
Send rel look for 1.15 head rotation packet
This commit is contained in:
parent
f28e520b09
commit
7c89c9ca50
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user