Fix look packets being weird in 1.8

This commit is contained in:
libraryaddict 2014-09-05 05:22:26 +12:00
parent e65613e750
commit 4853015bd8

@ -1299,28 +1299,28 @@ public class PacketsManager {
packets = new PacketContainer[0]; packets = new PacketContainer[0];
} else { } else {
packets[0] = sentPacket.shallowClone(); packets[0] = sentPacket.shallowClone();
StructureModifier<Object> mods = packets[0].getModifier(); StructureModifier<Byte> bytes = packets[0].getBytes();
byte yawValue = (Byte) mods.read(4); boolean tele = sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT;
mods.write(4, getYaw(disguise.getType(), entity.getType(), yawValue)); byte yawValue = (Byte) bytes.read(tele ? 0 : 3);
byte pitchValue = (Byte) mods.read(5); bytes.write(3, getYaw(disguise.getType(), entity.getType(), yawValue));
mods.write(5, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue)); byte pitchValue = (Byte) bytes.read(tele ? 1 : 4);
if (sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT) { bytes.write(4, getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue));
if (disguise.getType() == DisguiseType.ITEM_FRAME) { if (tele && disguise.getType() == DisguiseType.ITEM_FRAME) {
Location loc = entity.getLocation(); StructureModifier<Integer> ints = packets[0].getIntegers();
int data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4; Location loc = entity.getLocation();
int data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4;
if (data % 2 == 0) {
if (data % 2 == 0) { if (data % 2 == 0) {
if (data % 2 == 0) { ints.write(3, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D));
mods.write(3, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D)); } else {
} else { ints.write(1, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D));
mods.write(1, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D));
}
}
double y = getYModifier(entity, disguise);
if (y != 0) {
y *= 32;
mods.write(2, (Integer) mods.read(2) + (int) Math.floor(y));
} }
} }
double y = getYModifier(entity, disguise);
if (y != 0) {
y *= 32;
ints.write(2, (Integer) ints.read(2) + (int) Math.floor(y));
}
} }
} }
} }