/**
* called every tick when the player is on foot. Performs all the things that normally happen during movement.
*/
public void onUpdateWalkingPlayer(UpdateMotionEvent updateMotionEvent, float yaw, float pitch) {
boolean flag = this.isSprinting();
if (flag != this.serverSprintState) {
if (flag) {
this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SPRINTING));
} else {
this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SPRINTING));
}
PlayerHandler.shouldSprintReset = false;
this.serverSprintState = flag;
}
boolean flag1 = this.isSneaking();
if (flag1 != this.serverSneakState) {
if (flag1) {
this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.START_SNEAKING));
} else {
this.sendQueue.addToSendQueue(new C0BPacketEntityAction(this, C0BPacketEntityAction.Action.STOP_SNEAKING));
}
this.serverSneakState = flag1;
}
if (updateMotionEvent.isCurrentView()) {
double d0 = this.posX - this.lastReportedPosX;
double d1 = this.getEntityBoundingBox().minY - this.lastReportedPosY;
double d2 = this.posZ - this.lastReportedPosZ;
double d3 = (double) (yaw - this.lastReportedYaw);
double d4 = (double) (pitch - this.lastReportedPitch);
boolean flag2 = d0 * d0 + d1 * d1 + d2 * d2 > 9.0E-4D || this.positionUpdateTicks >= 20;
boolean flag3 = d3 != 0.0D || d4 != 0.0D;
if (this.ridingEntity == null) {
if (flag2 && flag3) {
this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(this.posX, this.getEntityBoundingBox().minY, this.posZ, yaw, pitch, this.onGround));
} else if (flag2) {
this.sendQueue.addToSendQueue(new C03PacketPlayer.C04PacketPlayerPosition(this.posX, this.getEntityBoundingBox().minY, this.posZ, this.onGround));
} else if (flag3) {
this.sendQueue.addToSendQueue(new C03PacketPlayer.C05PacketPlayerLook(yaw, pitch, this.onGround));
} else {
this.sendQueue.addToSendQueue(new C03PacketPlayer(this.onGround));
}
} else {
final RidingEntityEvent ridingEntityEvent = new RidingEntityEvent(this.motionX, -999D, this.motionZ, this.onGround).publishItself();
this.sendQueue.addToSendQueue(new C03PacketPlayer.C06PacketPlayerPosLook(ridingEntityEvent.getMotionX(), ridingEntityEvent.getMotionY(), ridingEntityEvent.getMotionZ(), yaw, pitch, ridingEntityEvent.isOnGround()));
flag2 = false;
}
++this.positionUpdateTicks;
if (flag2) {
this.lastReportedPosX = this.posX;
this.lastReportedPosY = this.getEntityBoundingBox().minY;
this.lastReportedPosZ = this.posZ;
this.positionUpdateTicks = 0;
}
if (flag3) {
this.lastReportedYaw = yaw;
this.lastReportedPitch = pitch;
}
new UpdateMotionEvent(UpdateMotionEvent.Type.POST, updateMotionEvent.isCurrentView()).publishItself();
}
}