While Recording, only insert S19PacketEntityHeadLook for recording player if value actually changed | https://trello.com/c/9MZeTBgj/

This commit is contained in:
CrushedPixel
2015-06-29 15:35:12 +02:00
parent f52ed6d92b
commit fb12119e5c

View File

@@ -38,6 +38,7 @@ public class RecordingHandler {
private int ticksSinceLastCorrection = 0; private int ticksSinceLastCorrection = 0;
private boolean wasSleeping = false; private boolean wasSleeping = false;
private int lastRiding = -1; private int lastRiding = -1;
private Integer rotationYawHeadBefore = 0;
@SubscribeEvent @SubscribeEvent
public void onPlayerJoin(EntityJoinWorldEvent e) { public void onPlayerJoin(EntityJoinWorldEvent e) {
@@ -104,6 +105,7 @@ public class RecordingHandler {
public void resetVars() { public void resetVars() {
lastX = lastY = lastZ = null; lastX = lastY = lastZ = null;
rotationYawHeadBefore = null;
lastEffects = new ArrayList<Integer>(); lastEffects = new ArrayList<Integer>();
playerItems = new ItemStack[5]; playerItems = new ItemStack[5];
} }
@@ -162,16 +164,22 @@ public class RecordingHandler {
ConnectionEventHandler.insertPacket(packet); ConnectionEventHandler.insertPacket(packet);
//HEAD POS //HEAD POS
S19PacketEntityHeadLook head = new S19PacketEntityHeadLook(); int rotationYawHead = ((int)(e.player.rotationYawHead * 256.0F / 360.0F));
ByteBuf bb1 = Unpooled.buffer();
PacketBuffer pb1 = new PacketBuffer(bb1);
pb1.writeVarIntToBuffer(entityID); if(rotationYawHead != rotationYawHeadBefore) {
pb1.writeByte(((int) (e.player.rotationYawHead * 256.0F / 360.0F))); S19PacketEntityHeadLook head = new S19PacketEntityHeadLook();
ByteBuf bb1 = Unpooled.buffer();
PacketBuffer pb1 = new PacketBuffer(bb1);
head.readPacketData(pb1); pb1.writeVarIntToBuffer(entityID);
pb1.writeByte(rotationYawHead);
ConnectionEventHandler.insertPacket(head); head.readPacketData(pb1);
ConnectionEventHandler.insertPacket(head);
rotationYawHeadBefore = rotationYawHead;
}
S12PacketEntityVelocity vel = new S12PacketEntityVelocity(entityID, e.player.motionX, e.player.motionY, e.player.motionZ); S12PacketEntityVelocity vel = new S12PacketEntityVelocity(entityID, e.player.motionX, e.player.motionY, e.player.motionZ);
ConnectionEventHandler.insertPacket(vel); ConnectionEventHandler.insertPacket(vel);