/** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (!this.worldObj.isRemote) { int i = this.getArrowCountInEntity(); if (i > 0) { if (this.arrowHitTimer <= 0) { this.arrowHitTimer = 20 * (30 - i); } --this.arrowHitTimer; if (this.arrowHitTimer <= 0) { this.setArrowCountInEntity(i - 1); } } for (int j = 0; j < 5; ++j) { ItemStack itemstack = this.previousEquipment[j]; ItemStack itemstack1 = this.getEquipmentInSlot(j); if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) { ((WorldServer)this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1)); if (itemstack != null) { this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers()); } if (itemstack1 != null) { this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers()); } this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy(); } } if (this.ticksExisted % 20 == 0) { this.getCombatTracker().reset(); } } this.onLivingUpdate(); double deltaX = this.posX - this.prevPosX; double deltaZ = this.posZ - this.prevPosZ; float distance = (float) (deltaX * deltaX + deltaZ * deltaZ); float yawHead = rotationYawHead; if(this == Minecraft.getMinecraft().thePlayer) yawHead = PlayerHandler.yaw; float offset = renderYawOffset; float f2 = 0.0F; this.prevOnGroundSpeedFactor = this.onGroundSpeedFactor; float f3 = 0.0F; if (distance > 0.0025000002F) offset = (float) MathHelper.func_181159_b(deltaZ, deltaX) * 180.0F / (float) Math.PI - 90.0F; if (this.swingProgress > 0.0F) offset = yawHead; if (!this.onGround) { f3 = 0.0F; } this.onGroundSpeedFactor += (f3 - this.onGroundSpeedFactor) * 0.3F; this.worldObj.theProfiler.startSection("headTurn"); f2 = this.func_110146_f(offset, f2); this.worldObj.theProfiler.endSection(); this.worldObj.theProfiler.startSection("rangeChecks"); while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } while (this.renderYawOffset - this.prevRenderYawOffset < -180.0F) { this.prevRenderYawOffset -= 360.0F; } while (this.renderYawOffset - this.prevRenderYawOffset >= 180.0F) { this.prevRenderYawOffset += 360.0F; } while (this.rotationPitch - this.prevRotationPitch < -180.0F) { this.prevRotationPitch -= 360.0F; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYawHead - this.prevRotationYawHead < -180.0F) { this.prevRotationYawHead -= 360.0F; } while (this.rotationYawHead - this.prevRotationYawHead >= 180.0F) { this.prevRotationYawHead += 360.0F; } this.worldObj.theProfiler.endSection(); this.movedDistance += f2; }