Advertisement
GamingLVScripts

onUpdate

Apr 1st, 2024
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.90 KB | None | 0 0
  1. /**
  2.      * Called to update the entity's position/logic.
  3.      */
  4.     public void onUpdate()
  5.     {
  6.         super.onUpdate();
  7.  
  8.         if (!this.worldObj.isRemote)
  9.         {
  10.             int i = this.getArrowCountInEntity();
  11.  
  12.             if (i > 0)
  13.             {
  14.                 if (this.arrowHitTimer <= 0)
  15.                 {
  16.                     this.arrowHitTimer = 20 * (30 - i);
  17.                 }
  18.  
  19.                 --this.arrowHitTimer;
  20.  
  21.                 if (this.arrowHitTimer <= 0)
  22.                 {
  23.                     this.setArrowCountInEntity(i - 1);
  24.                 }
  25.             }
  26.  
  27.             for (int j = 0; j < 5; ++j)
  28.             {
  29.                 ItemStack itemstack = this.previousEquipment[j];
  30.                 ItemStack itemstack1 = this.getEquipmentInSlot(j);
  31.  
  32.                 if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
  33.                 {
  34.                     ((WorldServer)this.worldObj).getEntityTracker().sendToAllTrackingEntity(this, new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1));
  35.  
  36.                     if (itemstack != null)
  37.                     {
  38.                         this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers());
  39.                     }
  40.  
  41.                     if (itemstack1 != null)
  42.                     {
  43.                         this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers());
  44.                     }
  45.  
  46.                     this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy();
  47.                 }
  48.             }
  49.  
  50.             if (this.ticksExisted % 20 == 0)
  51.             {
  52.                 this.getCombatTracker().reset();
  53.             }
  54.         }
  55.  
  56.         this.onLivingUpdate();
  57.         double deltaX = this.posX - this.prevPosX;
  58.         double deltaZ = this.posZ - this.prevPosZ;
  59.         float distance = (float) (deltaX * deltaX + deltaZ * deltaZ);
  60.         float yawHead = rotationYawHead;
  61.         if(this == Minecraft.getMinecraft().thePlayer)
  62.             yawHead = PlayerHandler.yaw;
  63.         float offset = renderYawOffset;
  64.  
  65.         float f2 = 0.0F;
  66.         this.prevOnGroundSpeedFactor = this.onGroundSpeedFactor;
  67.         float f3 = 0.0F;
  68.  
  69.         if (distance > 0.0025000002F)
  70.             offset = (float) MathHelper.func_181159_b(deltaZ, deltaX) * 180.0F / (float) Math.PI - 90.0F;
  71.  
  72.         if (this.swingProgress > 0.0F)
  73.             offset = yawHead;
  74.  
  75.         if (!this.onGround) {
  76.             f3 = 0.0F;
  77.         }
  78.  
  79.         this.onGroundSpeedFactor += (f3 - this.onGroundSpeedFactor) * 0.3F;
  80.         this.worldObj.theProfiler.startSection("headTurn");
  81.         f2 = this.func_110146_f(offset, f2);
  82.         this.worldObj.theProfiler.endSection();
  83.         this.worldObj.theProfiler.startSection("rangeChecks");
  84.  
  85.         while (this.rotationYaw - this.prevRotationYaw < -180.0F) {
  86.             this.prevRotationYaw -= 360.0F;
  87.         }
  88.  
  89.         while (this.rotationYaw - this.prevRotationYaw >= 180.0F) {
  90.             this.prevRotationYaw += 360.0F;
  91.         }
  92.  
  93.         while (this.renderYawOffset - this.prevRenderYawOffset < -180.0F) {
  94.             this.prevRenderYawOffset -= 360.0F;
  95.         }
  96.  
  97.         while (this.renderYawOffset - this.prevRenderYawOffset >= 180.0F) {
  98.             this.prevRenderYawOffset += 360.0F;
  99.         }
  100.  
  101.         while (this.rotationPitch - this.prevRotationPitch < -180.0F) {
  102.             this.prevRotationPitch -= 360.0F;
  103.         }
  104.  
  105.         while (this.rotationPitch - this.prevRotationPitch >= 180.0F) {
  106.             this.prevRotationPitch += 360.0F;
  107.         }
  108.  
  109.         while (this.rotationYawHead - this.prevRotationYawHead < -180.0F) {
  110.             this.prevRotationYawHead -= 360.0F;
  111.         }
  112.  
  113.         while (this.rotationYawHead - this.prevRotationYawHead >= 180.0F) {
  114.             this.prevRotationYawHead += 360.0F;
  115.         }
  116.  
  117.         this.worldObj.theProfiler.endSection();
  118.         this.movedDistance += f2;
  119.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement