Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. public void moveEntityWithHeading(float strafe, float forward)
  2. {
  3. if (this.isServerWorld())
  4. {
  5. if (!this.isInWater() || this instanceof EntityPlayer && ((EntityPlayer)this).capabilities.isFlying)
  6. {
  7. if (!this.isInLava() || this instanceof EntityPlayer && ((EntityPlayer)this).capabilities.isFlying)
  8. {
  9. float f4 = 0.91F;
  10.  
  11. if (this.onGround)
  12. {
  13. f4 = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.91F;
  14. }
  15.  
  16. float f = 0.16277136F / (f4 * f4 * f4);
  17. float f5;
  18.  
  19. if (this.onGround)
  20. {
  21. f5 = this.getAIMoveSpeed() * f;
  22. }
  23. else
  24. {
  25. f5 = this.jumpMovementFactor;
  26. }
  27.  
  28. this.moveFlying(strafe, forward, f5);
  29. f4 = 0.91F;
  30.  
  31. if (this.onGround)
  32. {
  33. f4 = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.91F;
  34. }
  35.  
  36. if (this.isOnLadder())
  37. {
  38. float f6 = 0.15F;
  39. this.motionX = MathHelper.clamp_double(this.motionX, (double)(-f6), (double)f6);
  40. this.motionZ = MathHelper.clamp_double(this.motionZ, (double)(-f6), (double)f6);
  41. this.fallDistance = 0.0F;
  42.  
  43. if (this.motionY < -0.15D)
  44. {
  45. this.motionY = -0.15D;
  46. }
  47.  
  48. boolean flag = this.isSneaking() && this instanceof EntityPlayer;
  49.  
  50. if (flag && this.motionY < 0.0D)
  51. {
  52. this.motionY = 0.0D;
  53. }
  54. }
  55.  
  56. this.moveEntity(this.motionX, this.motionY, this.motionZ);
  57.  
  58. if (this.isCollidedHorizontally && this.isOnLadder())
  59. {
  60. this.motionY = 0.2D;
  61. }
  62.  
  63. if (this.worldObj.isRemote && (!this.worldObj.isBlockLoaded(new BlockPos((int)this.posX, 0, (int)this.posZ)) || !this.worldObj.getChunkFromBlockCoords(new BlockPos((int)this.posX, 0, (int)this.posZ)).isLoaded()))
  64. {
  65. if (this.posY > 0.0D)
  66. {
  67. this.motionY = -0.1D;
  68. }
  69. else
  70. {
  71. this.motionY = 0.0D;
  72. }
  73. }
  74. else
  75. {
  76. this.motionY -= 0.08D;
  77. }
  78.  
  79. this.motionY *= 0.9800000190734863D;
  80. this.motionX *= (double)f4;
  81. this.motionZ *= (double)f4;
  82. }
  83. else
  84. {
  85. double d1 = this.posY;
  86. this.moveFlying(strafe, forward, 0.02F);
  87. this.moveEntity(this.motionX, this.motionY, this.motionZ);
  88. this.motionX *= 0.5D;
  89. this.motionY *= 0.5D;
  90. this.motionZ *= 0.5D;
  91. this.motionY -= 0.02D;
  92.  
  93. if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6000000238418579D - this.posY + d1, this.motionZ))
  94. {
  95. this.motionY = 0.30000001192092896D;
  96. }
  97. }
  98. }
  99. else
  100. {
  101. double d0 = this.posY;
  102. float f1 = 0.8F;
  103. float f2 = 0.02F;
  104. float f3 = (float)EnchantmentHelper.getDepthStriderModifier(this);
  105.  
  106. if (f3 > 3.0F)
  107. {
  108. f3 = 3.0F;
  109. }
  110.  
  111. if (!this.onGround)
  112. {
  113. f3 *= 0.5F;
  114. }
  115.  
  116. if (f3 > 0.0F)
  117. {
  118. f1 += (0.54600006F - f1) * f3 / 3.0F;
  119. f2 += (this.getAIMoveSpeed() * 1.0F - f2) * f3 / 3.0F;
  120. }
  121.  
  122. this.moveFlying(strafe, forward, f2);
  123. this.moveEntity(this.motionX, this.motionY, this.motionZ);
  124. this.motionX *= (double)f1;
  125. this.motionY *= 0.800000011920929D;
  126. this.motionZ *= (double)f1;
  127. this.motionY -= 0.02D;
  128.  
  129. if (this.isCollidedHorizontally && this.isOffsetPositionInLiquid(this.motionX, this.motionY + 0.6000000238418579D - this.posY + d0, this.motionZ))
  130. {
  131. this.motionY = 0.30000001192092896D;
  132. }
  133. }
  134. }
  135.  
  136. this.prevLimbSwingAmount = this.limbSwingAmount;
  137. double d2 = this.posX - this.prevPosX;
  138. double d3 = this.posZ - this.prevPosZ;
  139. float f7 = MathHelper.sqrt_double(d2 * d2 + d3 * d3) * 4.0F;
  140.  
  141. if (f7 > 1.0F)
  142. {
  143. f7 = 1.0F;
  144. }
  145.  
  146. this.limbSwingAmount += (f7 - this.limbSwingAmount) * 0.4F;
  147. this.limbSwing += this.limbSwingAmount;
  148. }
  149.  
  150. /**
  151. * the movespeed used for the new AI system
  152. */
  153. public float getAIMoveSpeed()
  154. {
  155. return this.landMovementFactor;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement