Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 76.14 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5. import java.util.UUID;
  6.  
  7. import me.darkmagician6.morbid.Morbid;
  8. import me.darkmagician6.morbid.MorbidWrapper;
  9. import net.minecraft.client.Minecraft;
  10. import net.minecraft.server.MinecraftServer;
  11.  
  12. public abstract class Entity
  13. {
  14. private static int nextEntityID = 0;
  15. public int entityId;
  16. public static double renderDistanceWeight;
  17.  
  18. /**
  19. * Blocks entities from spawning when they do their AABB check to make sure the spot is clear of entities that can
  20. * prevent spawning.
  21. */
  22. public boolean preventEntitySpawning;
  23.  
  24. /** The entity that is riding this entity */
  25. public Entity riddenByEntity;
  26.  
  27. /** The entity we are currently riding */
  28. public Entity ridingEntity;
  29. public boolean field_98038_p;
  30.  
  31. /** Reference to the World object. */
  32. public World worldObj;
  33. public double prevPosX;
  34. public double prevPosY;
  35. public double prevPosZ;
  36.  
  37. /** Entity position X */
  38. public double posX;
  39.  
  40. /** Entity position Y */
  41. public double posY;
  42.  
  43. /** Entity position Z */
  44. public double posZ;
  45.  
  46. /** Entity motion X */
  47. public double motionX;
  48.  
  49. /** Entity motion Y */
  50. public double motionY;
  51.  
  52. /** Entity motion Z */
  53. public double motionZ;
  54.  
  55. /** Entity rotation Yaw */
  56. public float rotationYaw;
  57.  
  58. /** Entity rotation Pitch */
  59. public float rotationPitch;
  60. public float prevRotationYaw;
  61. public float prevRotationPitch;
  62.  
  63. /** Axis aligned bounding box. */
  64. public final AxisAlignedBB boundingBox;
  65. public boolean onGround;
  66.  
  67. /**
  68. * True if after a move this entity has collided with something on X- or Z-axis
  69. */
  70. public boolean isCollidedHorizontally;
  71.  
  72. /**
  73. * True if after a move this entity has collided with something on Y-axis
  74. */
  75. public boolean isCollidedVertically;
  76.  
  77. /**
  78. * True if after a move this entity has collided with something either vertically or horizontally
  79. */
  80. public boolean isCollided;
  81. public boolean velocityChanged;
  82. public static boolean isInWeb;
  83. public boolean field_70135_K;
  84.  
  85. /**
  86. * Gets set by setDead, so this must be the flag whether an Entity is dead (inactive may be better term)
  87. */
  88. public boolean isDead;
  89. public float yOffset;
  90.  
  91. /** How wide this entity is considered to be */
  92. public float width;
  93.  
  94. /** How high this entity is considered to be */
  95. public float height;
  96.  
  97. /** The previous ticks distance walked multiplied by 0.6 */
  98. public float prevDistanceWalkedModified;
  99.  
  100. /** The distance walked multiplied by 0.6 */
  101. public float distanceWalkedModified;
  102. public float distanceWalkedOnStepModified;
  103. public float fallDistance;
  104.  
  105. /**
  106. * The distance that has to be exceeded in order to triger a new step sound and an onEntityWalking event on a block
  107. */
  108. private int nextStepDistance;
  109.  
  110. /**
  111. * The entity's X coordinate at the previous tick, used to calculate position during rendering routines
  112. */
  113. public double lastTickPosX;
  114.  
  115. /**
  116. * The entity's Y coordinate at the previous tick, used to calculate position during rendering routines
  117. */
  118. public double lastTickPosY;
  119.  
  120. /**
  121. * The entity's Z coordinate at the previous tick, used to calculate position during rendering routines
  122. */
  123. public double lastTickPosZ;
  124. public float ySize;
  125.  
  126. /**
  127. * How high this entity can step up when running into a block to try to get over it (currently make note the entity
  128. * will always step up this amount and not just the amount needed)
  129. */
  130. public float stepHeight;
  131.  
  132. /**
  133. * Whether this entity won't clip with collision or not (make note it won't disable gravity)
  134. */
  135. public boolean noClip;
  136.  
  137. /**
  138. * Reduces the velocity applied by entity collisions by the specified percent.
  139. */
  140. public float entityCollisionReduction;
  141. protected Random rand;
  142.  
  143. /** How many ticks has this entity had ran since being alive */
  144. public int ticksExisted;
  145.  
  146. /**
  147. * The amount of ticks you have to stand inside of fire before be set on fire
  148. */
  149. public int fireResistance;
  150. private int fire;
  151.  
  152. /**
  153. * Whether this entity is currently inside of water (if it handles water movement that is)
  154. */
  155. public boolean inWater;
  156.  
  157. /**
  158. * Remaining time an entity will be "immune" to further damage after being hurt.
  159. */
  160. public int hurtResistantTime;
  161. private boolean firstUpdate;
  162.  
  163. /** downloadable location of player's skin */
  164. public String skinUrl;
  165.  
  166. /** downloadable location of player's cloak */
  167. public String cloakUrl;
  168. public boolean isImmuneToFire;
  169. protected DataWatcher dataWatcher;
  170. private double entityRiderPitchDelta;
  171. private double entityRiderYawDelta;
  172.  
  173. /** Has this entity been added to the chunk its within */
  174. public boolean addedToChunk;
  175. public int chunkCoordX;
  176. public int chunkCoordY;
  177. public int chunkCoordZ;
  178. public int serverPosX;
  179. public int serverPosY;
  180. public int serverPosZ;
  181.  
  182. /**
  183. * Render entity even if it is outside the camera frustum. Only true in EntityFish for now. Used in RenderGlobal:
  184. * render if ignoreFrustumCheck or in frustum.
  185. */
  186. public boolean ignoreFrustumCheck;
  187. public boolean isAirBorne;
  188. public int timeUntilPortal;
  189.  
  190. /** Whether the entity is inside a Portal */
  191. protected boolean inPortal;
  192. protected int field_82153_h;
  193.  
  194. /** Which dimension the player is in (-1 = the Nether, 0 = normal world) */
  195. public int dimension;
  196. protected int teleportDirection;
  197. private boolean invulnerable;
  198. private UUID entityUniqueID;
  199. public EnumEntitySize myEntitySize;
  200.  
  201. public Entity(World par1World)
  202. {
  203. this.entityId = nextEntityID++;
  204. this.renderDistanceWeight = 1.0D;
  205. this.preventEntitySpawning = false;
  206. this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
  207. this.onGround = false;
  208. this.isCollided = false;
  209. this.velocityChanged = false;
  210. this.field_70135_K = true;
  211. this.isDead = false;
  212. this.yOffset = 0.0F;
  213. this.width = 0.6F;
  214. this.height = 1.8F;
  215. this.prevDistanceWalkedModified = 0.0F;
  216. this.distanceWalkedModified = 0.0F;
  217. this.distanceWalkedOnStepModified = 0.0F;
  218. this.fallDistance = 0.0F;
  219. this.nextStepDistance = 1;
  220. this.ySize = 0.0F;
  221. this.stepHeight = 0.0F;
  222. this.noClip = false;
  223. this.entityCollisionReduction = 0.0F;
  224. this.rand = new Random();
  225. this.ticksExisted = 0;
  226. this.fireResistance = 1;
  227. this.fire = 0;
  228. this.inWater = false;
  229. this.hurtResistantTime = 0;
  230. this.firstUpdate = true;
  231. this.isImmuneToFire = false;
  232. this.dataWatcher = new DataWatcher();
  233. this.addedToChunk = false;
  234. this.teleportDirection = 0;
  235. this.invulnerable = false;
  236. this.entityUniqueID = UUID.randomUUID();
  237. this.myEntitySize = EnumEntitySize.SIZE_2;
  238. this.worldObj = par1World;
  239. this.setPosition(0.0D, 0.0D, 0.0D);
  240.  
  241. if (par1World != null)
  242. {
  243. this.dimension = par1World.provider.dimensionId;
  244. }
  245.  
  246. this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
  247. this.dataWatcher.addObject(1, Short.valueOf((short)300));
  248. this.entityInit();
  249. }
  250.  
  251. protected abstract void entityInit();
  252.  
  253. public DataWatcher getDataWatcher()
  254. {
  255. return this.dataWatcher;
  256. }
  257.  
  258. public boolean equals(Object par1Obj)
  259. {
  260. return par1Obj instanceof Entity ? ((Entity)par1Obj).entityId == this.entityId : false;
  261. }
  262.  
  263. public int hashCode()
  264. {
  265. return this.entityId;
  266. }
  267.  
  268. /**
  269. * Keeps moving the entity up so it isn't colliding with blocks and other requirements for this entity to be spawned
  270. * (only actually used on players though its also on Entity)
  271. */
  272. protected void preparePlayerToSpawn()
  273. {
  274. if (this.worldObj != null)
  275. {
  276. while (this.posY > 0.0D)
  277. {
  278. this.setPosition(this.posX, this.posY, this.posZ);
  279.  
  280. if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty())
  281. {
  282. break;
  283. }
  284.  
  285. ++this.posY;
  286. }
  287.  
  288. this.motionX = this.motionY = this.motionZ = 0.0D;
  289. this.rotationPitch = 0.0F;
  290. }
  291. }
  292.  
  293. /**
  294. * Will get destroyed next tick.
  295. */
  296. public void setDead()
  297. {
  298. this.isDead = true;
  299. }
  300.  
  301. /**
  302. * Sets the width and height of the entity. Args: width, height
  303. */
  304. protected void setSize(float par1, float par2)
  305. {
  306. if (par1 != this.width || par2 != this.height)
  307. {
  308. this.width = par1;
  309. this.height = par2;
  310. this.boundingBox.maxX = this.boundingBox.minX + (double)this.width;
  311. this.boundingBox.maxZ = this.boundingBox.minZ + (double)this.width;
  312. this.boundingBox.maxY = this.boundingBox.minY + (double)this.height;
  313. }
  314.  
  315. float var3 = par1 % 2.0F;
  316.  
  317. if ((double)var3 < 0.375D)
  318. {
  319. this.myEntitySize = EnumEntitySize.SIZE_1;
  320. }
  321. else if ((double)var3 < 0.75D)
  322. {
  323. this.myEntitySize = EnumEntitySize.SIZE_2;
  324. }
  325. else if ((double)var3 < 1.0D)
  326. {
  327. this.myEntitySize = EnumEntitySize.SIZE_3;
  328. }
  329. else if ((double)var3 < 1.375D)
  330. {
  331. this.myEntitySize = EnumEntitySize.SIZE_4;
  332. }
  333. else if ((double)var3 < 1.75D)
  334. {
  335. this.myEntitySize = EnumEntitySize.SIZE_5;
  336. }
  337. else
  338. {
  339. this.myEntitySize = EnumEntitySize.SIZE_6;
  340. }
  341. }
  342.  
  343. /**
  344. * Sets the rotation of the entity
  345. */
  346. protected void setRotation(float par1, float par2)
  347. {
  348. this.rotationYaw = par1 % 360.0F;
  349. this.rotationPitch = par2 % 360.0F;
  350. }
  351.  
  352. /**
  353. * Sets the x,y,z of the entity from the given parameters. Also seems to set up a bounding box.
  354. */
  355. public void setPosition(double par1, double par3, double par5)
  356. {
  357. this.posX = par1;
  358. this.posY = par3;
  359. this.posZ = par5;
  360. float var7 = this.width / 2.0F;
  361. float var8 = this.height;
  362. this.boundingBox.setBounds(par1 - (double)var7, par3 - (double)this.yOffset + (double)this.ySize, par5 - (double)var7, par1 + (double)var7, par3 - (double)this.yOffset + (double)this.ySize + (double)var8, par5 + (double)var7);
  363. }
  364.  
  365. /**
  366. * Adds par1*0.15 to the entity's yaw, and *subtracts* par2*0.15 from the pitch. Clamps pitch from -90 to 90. Both
  367. * arguments in degrees.
  368. */
  369. public void setAngles(float par1, float par2)
  370. {
  371. float var3 = this.rotationPitch;
  372. float var4 = this.rotationYaw;
  373. this.rotationYaw = (float)((double)this.rotationYaw + (double)par1 * 0.15D);
  374. this.rotationPitch = (float)((double)this.rotationPitch - (double)par2 * 0.15D)
  375.  
  376. if (this.rotationPitch < -90.0F)
  377. {
  378. this.rotationPitch = -90.0F;
  379. }
  380.  
  381. if (this.rotationPitch > 90.0F)
  382. {
  383. this.rotationPitch = 90.0F;
  384. }
  385.  
  386. this.prevRotationPitch += this.rotationPitch - var3;
  387. this.prevRotationYaw += this.rotationYaw - var4;
  388. }
  389.  
  390. /**
  391. * Called to update the entity's position/logic.
  392. */
  393. public void onUpdate()
  394. {
  395. this.onEntityUpdate();
  396. }
  397.  
  398. /**
  399. * Gets called every tick from main Entity class
  400. */
  401. public void onEntityUpdate()
  402. {
  403. this.worldObj.theProfiler.startSection("entityBaseTick");
  404.  
  405. if (this.ridingEntity != null && this.ridingEntity.isDead)
  406. {
  407. this.ridingEntity = null;
  408. }
  409.  
  410. this.prevDistanceWalkedModified = this.distanceWalkedModified;
  411. this.prevPosX = this.posX;
  412. this.prevPosY = this.posY;
  413. this.prevPosZ = this.posZ;
  414. this.prevRotationPitch = this.rotationPitch;
  415. this.prevRotationYaw = this.rotationYaw;
  416. int var1;
  417.  
  418. if (!this.worldObj.isRemote && this.worldObj instanceof WorldServer)
  419. {
  420. this.worldObj.theProfiler.startSection("portal");
  421. MinecraftServer var2 = ((WorldServer)this.worldObj).getMinecraftServer();
  422. var1 = this.getMaxInPortalTime();
  423.  
  424. if (this.inPortal)
  425. {
  426. if (var2.getAllowNether())
  427. {
  428. if (this.ridingEntity == null && this.field_82153_h++ >= var1)
  429. {
  430. this.field_82153_h = var1;
  431. this.timeUntilPortal = this.getPortalCooldown();
  432. byte var3;
  433.  
  434. if (this.worldObj.provider.dimensionId == -1)
  435. {
  436. var3 = 0;
  437. }
  438. else
  439. {
  440. var3 = -1;
  441. }
  442.  
  443. this.travelToDimension(var3);
  444. }
  445.  
  446. this.inPortal = false;
  447. }
  448. }
  449. else
  450. {
  451. if (this.field_82153_h > 0)
  452. {
  453. this.field_82153_h -= 4;
  454. }
  455.  
  456. if (this.field_82153_h < 0)
  457. {
  458. this.field_82153_h = 0;
  459. }
  460. }
  461.  
  462. if (this.timeUntilPortal > 0)
  463. {
  464. --this.timeUntilPortal;
  465. }
  466.  
  467. this.worldObj.theProfiler.endSection();
  468. }
  469.  
  470. if (this.isSprinting() && !this.isInWater())
  471. {
  472. int var5 = MathHelper.floor_double(this.posX);
  473. var1 = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
  474. int var6 = MathHelper.floor_double(this.posZ);
  475. int var4 = this.worldObj.getBlockId(var5, var1, var6);
  476.  
  477. if (var4 > 0)
  478. {
  479. this.worldObj.spawnParticle("tilecrack_" + var4 + "_" + this.worldObj.getBlockMetadata(var5, var1, var6), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, -this.motionX * 4.0D, 1.5D, -this.motionZ * 4.0D);
  480. }
  481. }
  482.  
  483. this.handleWaterMovement();
  484.  
  485. if (this.worldObj.isRemote)
  486. {
  487. this.fire = 0;
  488. }
  489. else if (this.fire > 0)
  490. {
  491. if (this.isImmuneToFire)
  492. {
  493. this.fire -= 4;
  494.  
  495. if (this.fire < 0)
  496. {
  497. this.fire = 0;
  498. }
  499. }
  500. else
  501. {
  502. if (this.fire % 20 == 0)
  503. {
  504. this.attackEntityFrom(DamageSource.onFire, 1);
  505. }
  506.  
  507. --this.fire;
  508. }
  509. }
  510.  
  511. if (this.handleLavaMovement())
  512. {
  513. this.setOnFireFromLava();
  514. this.fallDistance *= 0.5F;
  515. }
  516.  
  517. if (this.posY < -64.0D)
  518. {
  519. this.kill();
  520. }
  521.  
  522. if (!this.worldObj.isRemote)
  523. {
  524. this.setFlag(0, this.fire > 0);
  525. this.setFlag(2, this.ridingEntity != null);
  526. }
  527.  
  528. this.firstUpdate = false;
  529. this.worldObj.theProfiler.endSection();
  530. }
  531.  
  532. /**
  533. * Return the amount of time this entity should stay in a portal before being transported.
  534. */
  535. public int getMaxInPortalTime()
  536. {
  537. return 0;
  538. }
  539.  
  540. /**
  541. * Called whenever the entity is walking inside of lava.
  542. */
  543. protected void setOnFireFromLava()
  544. {
  545. if (!this.isImmuneToFire)
  546. {
  547. this.attackEntityFrom(DamageSource.lava, 4);
  548. this.setFire(15);
  549. }
  550. }
  551.  
  552. /**
  553. * Sets entity to burn for x amount of seconds, cannot lower amount of existing fire.
  554. */
  555. public void setFire(int par1)
  556. {
  557. int var2 = par1 * 20;
  558. var2 = EnchantmentProtection.func_92093_a(this, var2);
  559.  
  560. if (this.fire < var2)
  561. {
  562. this.fire = var2;
  563. }
  564. }
  565.  
  566. /**
  567. * Removes fire from entity.
  568. */
  569. public void extinguish()
  570. {
  571. this.fire = 0;
  572. }
  573.  
  574. /**
  575. * sets the dead flag. Used when you fall off the bottom of the world.
  576. */
  577. protected void kill()
  578. {
  579. this.setDead();
  580. }
  581.  
  582. /**
  583. * Checks if the offset position from the entity's current position is inside of liquid. Args: x, y, z
  584. */
  585. public boolean isOffsetPositionInLiquid(double par1, double par3, double par5)
  586. {
  587. AxisAlignedBB var7 = this.boundingBox.getOffsetBoundingBox(par1, par3, par5);
  588. List var8 = this.worldObj.getCollidingBoundingBoxes(this, var7);
  589. return !var8.isEmpty() ? false : !this.worldObj.isAnyLiquid(var7);
  590. }
  591.  
  592. /**
  593. * Tries to moves the entity by the passed in displacement. Args: x, y, z
  594. */
  595. public void moveEntity(double par1, double par3, double par5)
  596. {
  597. if (this.noClip)
  598. {
  599. this.boundingBox.offset(par1, par3, par5);
  600. this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D;
  601. this.posY = this.boundingBox.minY + (double)this.yOffset - (double)this.ySize;
  602. this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D;
  603. }
  604. else
  605. {
  606. this.worldObj.theProfiler.startSection("move");
  607. this.ySize *= 0.4F;
  608. double var7 = this.posX;
  609. double var9 = this.posY;
  610. double var11 = this.posZ;
  611.  
  612. if (this.isInWeb)
  613. {
  614. this.isInWeb = false;
  615. par1 *= 0.25D;
  616. par3 *= 0.05000000074505806D;
  617. par5 *= 0.25D;
  618. this.motionX = 0.0D;
  619. this.motionY = 0.0D;
  620. this.motionZ = 0.0D;
  621. }
  622.  
  623. double var13 = par1;
  624. double var15 = par3;
  625. double var17 = par5;
  626. AxisAlignedBB var19 = this.boundingBox.copy();
  627. boolean var20 = this.onGround && this.isSneaking() && this instanceof EntityPlayer;
  628.  
  629. if (var20 || (Morbid.getManager().getMod("safewalk").isEnabled()) && !Minecraft.getMinecraft().thePlayer.isJumping)
  630. {
  631. double var21;
  632.  
  633. for (var21 = 0.05D; par1 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(par1, -1.0D, 0.0D)).isEmpty(); var13 = par1)
  634. {
  635. if (par1 < var21 && par1 >= -var21)
  636. {
  637. par1 = 0.0D;
  638. }
  639. else if (par1 > 0.0D)
  640. {
  641. par1 -= var21;
  642. }
  643. else
  644. {
  645. par1 += var21;
  646. }
  647. }
  648.  
  649. for (; par5 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(0.0D, -1.0D, par5)).isEmpty(); var17 = par5)
  650. {
  651. if (par5 < var21 && par5 >= -var21)
  652. {
  653. par5 = 0.0D;
  654. }
  655. else if (par5 > 0.0D)
  656. {
  657. par5 -= var21;
  658. }
  659. else
  660. {
  661. par5 += var21;
  662. }
  663. }
  664.  
  665. while (par1 != 0.0D && par5 != 0.0D && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.getOffsetBoundingBox(par1, -1.0D, par5)).isEmpty())
  666. {
  667. if (par1 < var21 && par1 >= -var21)
  668. {
  669. par1 = 0.0D;
  670. }
  671. else if (par1 > 0.0D)
  672. {
  673. par1 -= var21;
  674. }
  675. else
  676. {
  677. par1 += var21;
  678. }
  679.  
  680. if (par5 < var21 && par5 >= -var21)
  681. {
  682. par5 = 0.0D;
  683. }
  684. else if (par5 > 0.0D)
  685. {
  686. par5 -= var21;
  687. }
  688. else
  689. {
  690. par5 += var21;
  691. }
  692.  
  693. var13 = par1;
  694. var17 = par5;
  695. }
  696. }
  697.  
  698. List var36 = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(par1, par3, par5));
  699.  
  700. for (int var22 = 0; var22 < var36.size(); ++var22)
  701. {
  702. par3 = ((AxisAlignedBB)var36.get(var22)).calculateYOffset(this.boundingBox, par3);
  703. }
  704.  
  705. this.boundingBox.offset(0.0D, par3, 0.0D);
  706.  
  707. if (!this.field_70135_K && var15 != par3)
  708. {
  709. par5 = 0.0D;
  710. par3 = 0.0D;
  711. par1 = 0.0D;
  712. }
  713.  
  714. boolean var35 = this.onGround || var15 != par3 && var15 < 0.0D;
  715. int var23;
  716.  
  717. for (var23 = 0; var23 < var36.size(); ++var23)
  718. {
  719. par1 = ((AxisAlignedBB)var36.get(var23)).calculateXOffset(this.boundingBox, par1);
  720. }
  721.  
  722. this.boundingBox.offset(par1, 0.0D, 0.0D);
  723.  
  724. if (!this.field_70135_K && var13 != par1)
  725. {
  726. par5 = 0.0D;
  727. par3 = 0.0D;
  728. par1 = 0.0D;
  729. }
  730.  
  731. for (var23 = 0; var23 < var36.size(); ++var23)
  732. {
  733. par5 = ((AxisAlignedBB)var36.get(var23)).calculateZOffset(this.boundingBox, par5);
  734. }
  735.  
  736. this.boundingBox.offset(0.0D, 0.0D, par5);
  737.  
  738. if (!this.field_70135_K && var17 != par5)
  739. {
  740. par5 = 0.0D;
  741. par3 = 0.0D;
  742. par1 = 0.0D;
  743. }
  744.  
  745. double var24;
  746. double var26;
  747. double var29;
  748. int var28;
  749.  
  750. if (this.stepHeight > 0.0F && var35 && (var20 || this.ySize < 0.05F) && (var13 != par1 || var17 != par5))
  751. {
  752. var29 = par1;
  753. var24 = par3;
  754. var26 = par5;
  755. par1 = var13;
  756. par3 = (double)this.stepHeight;
  757. par5 = var17;
  758. AxisAlignedBB var31 = this.boundingBox.copy();
  759. this.boundingBox.setBB(var19);
  760. var36 = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.addCoord(var13, par3, var17));
  761.  
  762. for (var28 = 0; var28 < var36.size(); ++var28)
  763. {
  764. par3 = ((AxisAlignedBB)var36.get(var28)).calculateYOffset(this.boundingBox, par3);
  765. }
  766.  
  767. this.boundingBox.offset(0.0D, par3, 0.0D);
  768.  
  769. if (!this.field_70135_K && var15 != par3)
  770. {
  771. par5 = 0.0D;
  772. par3 = 0.0D;
  773. par1 = 0.0D;
  774. }
  775.  
  776. for (var28 = 0; var28 < var36.size(); ++var28)
  777. {
  778. par1 = ((AxisAlignedBB)var36.get(var28)).calculateXOffset(this.boundingBox, par1);
  779. }
  780.  
  781. this.boundingBox.offset(par1, 0.0D, 0.0D);
  782.  
  783. if (!this.field_70135_K && var13 != par1)
  784. {
  785. par5 = 0.0D;
  786. par3 = 0.0D;
  787. par1 = 0.0D;
  788. }
  789.  
  790. for (var28 = 0; var28 < var36.size(); ++var28)
  791. {
  792. par5 = ((AxisAlignedBB)var36.get(var28)).calculateZOffset(this.boundingBox, par5);
  793. }
  794.  
  795. this.boundingBox.offset(0.0D, 0.0D, par5);
  796.  
  797. if (!this.field_70135_K && var17 != par5)
  798. {
  799. par5 = 0.0D;
  800. par3 = 0.0D;
  801. par1 = 0.0D;
  802. }
  803.  
  804. if (!this.field_70135_K && var15 != par3)
  805. {
  806. par5 = 0.0D;
  807. par3 = 0.0D;
  808. par1 = 0.0D;
  809. }
  810. else
  811. {
  812. par3 = (double)(-this.stepHeight);
  813.  
  814. for (var28 = 0; var28 < var36.size(); ++var28)
  815. {
  816. par3 = ((AxisAlignedBB)var36.get(var28)).calculateYOffset(this.boundingBox, par3);
  817. }
  818.  
  819. this.boundingBox.offset(0.0D, par3, 0.0D);
  820. }
  821.  
  822. if (var29 * var29 + var26 * var26 >= par1 * par1 + par5 * par5)
  823. {
  824. par1 = var29;
  825. par3 = var24;
  826. par5 = var26;
  827. this.boundingBox.setBB(var31);
  828. }
  829. }
  830.  
  831. this.worldObj.theProfiler.endSection();
  832. this.worldObj.theProfiler.startSection("rest");
  833. this.posX = (this.boundingBox.minX + this.boundingBox.maxX) / 2.0D;
  834. this.posY = this.boundingBox.minY + (double)this.yOffset - (double)this.ySize;
  835. this.posZ = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2.0D;
  836. this.isCollidedHorizontally = var13 != par1 || var17 != par5;
  837. this.isCollidedVertically = var15 != par3;
  838. this.onGround = var15 != par3 && var15 < 0.0D;
  839. this.isCollided = this.isCollidedHorizontally || this.isCollidedVertically;
  840. this.updateFallState(par3, this.onGround);
  841.  
  842. if (var13 != par1)
  843. {
  844. this.motionX = 0.0D;
  845. }
  846.  
  847. if (var15 != par3)
  848. {
  849. this.motionY = 0.0D;
  850. }
  851.  
  852. if (var17 != par5)
  853. {
  854. this.motionZ = 0.0D;
  855. }
  856.  
  857. var29 = this.posX - var7;
  858. var24 = this.posY - var9;
  859. var26 = this.posZ - var11;
  860.  
  861. if (this.canTriggerWalking() && !var20 && this.ridingEntity == null)
  862. {
  863. int var37 = MathHelper.floor_double(this.posX);
  864. var28 = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
  865. int var32 = MathHelper.floor_double(this.posZ);
  866. int var33 = this.worldObj.getBlockId(var37, var28, var32);
  867.  
  868. if (var33 == 0)
  869. {
  870. int var34 = this.worldObj.blockGetRenderType(var37, var28 - 1, var32);
  871.  
  872. if (var34 == 11 || var34 == 32 || var34 == 21)
  873. {
  874. var33 = this.worldObj.getBlockId(var37, var28 - 1, var32);
  875. }
  876. }
  877.  
  878. if (var33 != Block.ladder.blockID)
  879. {
  880. var24 = 0.0D;
  881. }
  882.  
  883. this.distanceWalkedModified = (float)((double)this.distanceWalkedModified + (double)MathHelper.sqrt_double(var29 * var29 + var26 * var26) * 0.6D);
  884. this.distanceWalkedOnStepModified = (float)((double)this.distanceWalkedOnStepModified + (double)MathHelper.sqrt_double(var29 * var29 + var24 * var24 + var26 * var26) * 0.6D);
  885.  
  886. if (this.distanceWalkedOnStepModified > (float)this.nextStepDistance && var33 > 0)
  887. {
  888. this.nextStepDistance = (int)this.distanceWalkedOnStepModified + 1;
  889.  
  890. if (this.isInWater())
  891. {
  892. float var39 = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.35F;
  893.  
  894. if (var39 > 1.0F)
  895. {
  896. var39 = 1.0F;
  897. }
  898.  
  899. this.playSound("liquid.swim", var39, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
  900. }
  901.  
  902. this.playStepSound(var37, var28, var32, var33);
  903. Block.blocksList[var33].onEntityWalking(this.worldObj, var37, var28, var32, this);
  904. }
  905. }
  906.  
  907. this.doBlockCollisions();
  908. boolean var38 = this.isWet();
  909.  
  910. if (this.worldObj.isBoundingBoxBurning(this.boundingBox.contract(0.001D, 0.001D, 0.001D)))
  911. {
  912. this.dealFireDamage(1);
  913.  
  914. if (!var38)
  915. {
  916. ++this.fire;
  917.  
  918. if (this.fire == 0)
  919. {
  920. this.setFire(8);
  921. }
  922. }
  923. }
  924. else if (this.fire <= 0)
  925. {
  926. this.fire = -this.fireResistance;
  927. }
  928.  
  929. if (var38 && this.fire > 0)
  930. {
  931. this.playSound("random.fizz", 0.7F, 1.6F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
  932. this.fire = -this.fireResistance;
  933. }
  934.  
  935. this.worldObj.theProfiler.endSection();
  936. }
  937. }
  938.  
  939. /**
  940. * Checks for block collisions, and calls the associated onBlockCollided method for the collided block.
  941. */
  942. protected void doBlockCollisions()
  943. {
  944. int var1 = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
  945. int var2 = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
  946. int var3 = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
  947. int var4 = MathHelper.floor_double(this.boundingBox.maxX - 0.001D);
  948. int var5 = MathHelper.floor_double(this.boundingBox.maxY - 0.001D);
  949. int var6 = MathHelper.floor_double(this.boundingBox.maxZ - 0.001D);
  950.  
  951. if (this.worldObj.checkChunksExist(var1, var2, var3, var4, var5, var6))
  952. {
  953. for (int var7 = var1; var7 <= var4; ++var7)
  954. {
  955. for (int var8 = var2; var8 <= var5; ++var8)
  956. {
  957. for (int var9 = var3; var9 <= var6; ++var9)
  958. {
  959. int var10 = this.worldObj.getBlockId(var7, var8, var9);
  960.  
  961. if (var10 > 0)
  962. {
  963. Block.blocksList[var10].onEntityCollidedWithBlock(this.worldObj, var7, var8, var9, this);
  964. }
  965. }
  966. }
  967. }
  968. }
  969. }
  970.  
  971. /**
  972. * Plays step sound at given x, y, z for the entity
  973. */
  974. protected void playStepSound(int par1, int par2, int par3, int par4)
  975. {
  976. StepSound var5 = Block.blocksList[par4].stepSound;
  977.  
  978. if (this.worldObj.getBlockId(par1, par2 + 1, par3) == Block.snow.blockID)
  979. {
  980. var5 = Block.snow.stepSound;
  981. this.playSound(var5.getStepSound(), var5.getVolume() * 0.15F, var5.getPitch());
  982. }
  983. else if (!Block.blocksList[par4].blockMaterial.isLiquid())
  984. {
  985. this.playSound(var5.getStepSound(), var5.getVolume() * 0.15F, var5.getPitch());
  986. }
  987. }
  988.  
  989. public void playSound(String par1Str, float par2, float par3)
  990. {
  991. this.worldObj.playSoundAtEntity(this, par1Str, par2, par3);
  992. }
  993.  
  994. /**
  995. * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
  996. * prevent them from trampling crops
  997. */
  998. protected boolean canTriggerWalking()
  999. {
  1000. return true;
  1001. }
  1002.  
  1003. /**
  1004. * Takes in the distance the entity has fallen this tick and whether its on the ground to update the fall distance
  1005. * and deal fall damage if landing on the ground. Args: distanceFallenThisTick, onGround
  1006. */
  1007. protected void updateFallState(double par1, boolean par3)
  1008. {
  1009. if (par3)
  1010. {
  1011. if (this.fallDistance > 0.0F)
  1012. {
  1013. this.fall(this.fallDistance);
  1014. this.fallDistance = 0.0F;
  1015. }
  1016. }
  1017. else if (par1 < 0.0D)
  1018. {
  1019. this.fallDistance = (float)((double)this.fallDistance - par1);
  1020. }
  1021. }
  1022.  
  1023. /**
  1024. * returns the bounding box for this entity
  1025. */
  1026. public AxisAlignedBB getBoundingBox()
  1027. {
  1028. return null;
  1029. }
  1030.  
  1031. /**
  1032. * Will deal the specified amount of damage to the entity if the entity isn't immune to fire damage. Args:
  1033. * amountDamage
  1034. */
  1035. protected void dealFireDamage(int par1)
  1036. {
  1037. if (!this.isImmuneToFire)
  1038. {
  1039. this.attackEntityFrom(DamageSource.inFire, par1);
  1040. }
  1041. }
  1042.  
  1043. public final boolean isImmuneToFire()
  1044. {
  1045. return this.isImmuneToFire;
  1046. }
  1047.  
  1048. /**
  1049. * Called when the mob is falling. Calculates and applies fall damage.
  1050. */
  1051. protected void fall(float par1)
  1052. {
  1053. if (this.riddenByEntity != null)
  1054. {
  1055. this.riddenByEntity.fall(par1);
  1056. }
  1057. }
  1058.  
  1059. /**
  1060. * Checks if this entity is either in water or on an open air block in rain (used in wolves).
  1061. */
  1062. public boolean isWet()
  1063. {
  1064. return this.inWater || this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) || this.worldObj.canLightningStrikeAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY + (double)this.height), MathHelper.floor_double(this.posZ));
  1065. }
  1066.  
  1067. /**
  1068. * Checks if this entity is inside water (if inWater field is true as a result of handleWaterMovement() returning
  1069. * true)
  1070. */
  1071. public boolean isInWater()
  1072. {
  1073. return this.inWater;
  1074. }
  1075.  
  1076. /**
  1077. * Returns if this entity is in water and will end up adding the waters velocity to the entity
  1078. */
  1079. public boolean handleWaterMovement()
  1080. {
  1081. if (this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.4000000059604645D, 0.0D).contract(0.001D, 0.001D, 0.001D), Material.water, this))
  1082. {
  1083. if (!this.inWater && !this.firstUpdate)
  1084. {
  1085. float var1 = MathHelper.sqrt_double(this.motionX * this.motionX * 0.20000000298023224D + this.motionY * this.motionY + this.motionZ * this.motionZ * 0.20000000298023224D) * 0.2F;
  1086.  
  1087. if (var1 > 1.0F)
  1088. {
  1089. var1 = 1.0F;
  1090. }
  1091.  
  1092. this.playSound("liquid.splash", var1, 1.0F + (this.rand.nextFloat() - this.rand.nextFloat()) * 0.4F);
  1093. float var2 = (float)MathHelper.floor_double(this.boundingBox.minY);
  1094. int var3;
  1095. float var4;
  1096. float var5;
  1097.  
  1098. for (var3 = 0; (float)var3 < 1.0F + this.width * 20.0F; ++var3)
  1099. {
  1100. var4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
  1101. var5 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
  1102. this.worldObj.spawnParticle("bubble", this.posX + (double)var4, (double)(var2 + 1.0F), this.posZ + (double)var5, this.motionX, this.motionY - (double)(this.rand.nextFloat() * 0.2F), this.motionZ);
  1103. }
  1104.  
  1105. for (var3 = 0; (float)var3 < 1.0F + this.width * 20.0F; ++var3)
  1106. {
  1107. var4 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
  1108. var5 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
  1109. this.worldObj.spawnParticle("splash", this.posX + (double)var4, (double)(var2 + 1.0F), this.posZ + (double)var5, this.motionX, this.motionY, this.motionZ);
  1110. }
  1111. }
  1112.  
  1113. this.fallDistance = 0.0F;
  1114. this.inWater = true;
  1115. this.fire = 0;
  1116. }
  1117. else
  1118. {
  1119. this.inWater = false;
  1120. }
  1121.  
  1122. return this.inWater;
  1123. }
  1124.  
  1125. /**
  1126. * Checks if the current block the entity is within of the specified material type
  1127. */
  1128. public boolean isInsideOfMaterial(Material par1Material)
  1129. {
  1130. double var2 = this.posY + (double)this.getEyeHeight();
  1131. int var4 = MathHelper.floor_double(this.posX);
  1132. int var5 = MathHelper.floor_float((float)MathHelper.floor_double(var2));
  1133. int var6 = MathHelper.floor_double(this.posZ);
  1134. int var7 = this.worldObj.getBlockId(var4, var5, var6);
  1135.  
  1136. if (var7 != 0 && Block.blocksList[var7].blockMaterial == par1Material)
  1137. {
  1138. float var8 = BlockFluid.getFluidHeightPercent(this.worldObj.getBlockMetadata(var4, var5, var6)) - 0.11111111F;
  1139. float var9 = (float)(var5 + 1) - var8;
  1140. return var2 < (double)var9;
  1141. }
  1142. else
  1143. {
  1144. return false;
  1145. }
  1146. }
  1147.  
  1148. public float getEyeHeight()
  1149. {
  1150. return 0.0F;
  1151. }
  1152.  
  1153. /**
  1154. * Whether or not the current entity is in lava
  1155. */
  1156. public boolean handleLavaMovement()
  1157. {
  1158. return this.worldObj.isMaterialInBB(this.boundingBox.expand(-0.10000000149011612D, -0.4000000059604645D, -0.10000000149011612D), Material.lava);
  1159. }
  1160.  
  1161. /**
  1162. * Used in both water and by flying objects
  1163. */
  1164. public void moveFlying(float par1, float par2, float par3)
  1165. {
  1166. float var4 = par1 * par1 + par2 * par2;
  1167.  
  1168. if (var4 >= 1.0E-4F)
  1169. {
  1170. var4 = MathHelper.sqrt_float(var4);
  1171.  
  1172. if (var4 < 1.0F)
  1173. {
  1174. var4 = 1.0F;
  1175. }
  1176.  
  1177. var4 = par3 / var4;
  1178. par1 *= var4;
  1179. par2 *= var4;
  1180. float var5 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F);
  1181. float var6 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F);
  1182. this.motionX += (double)(par1 * var6 - par2 * var5);
  1183. this.motionZ += (double)(par2 * var6 + par1 * var5);
  1184. }
  1185. }
  1186.  
  1187. public int getBrightnessForRender(float par1)
  1188. {
  1189. int var2 = MathHelper.floor_double(this.posX);
  1190. int var3 = MathHelper.floor_double(this.posZ);
  1191.  
  1192. if (this.worldObj.blockExists(var2, 0, var3))
  1193. {
  1194. double var4 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D;
  1195. int var6 = MathHelper.floor_double(this.posY - (double)this.yOffset + var4);
  1196. return this.worldObj.getLightBrightnessForSkyBlocks(var2, var6, var3, 0);
  1197. }
  1198. else
  1199. {
  1200. return 0;
  1201. }
  1202. }
  1203.  
  1204. /**
  1205. * Gets how bright this entity is.
  1206. */
  1207. public float getBrightness(float par1)
  1208. {
  1209. int var2 = MathHelper.floor_double(this.posX);
  1210. int var3 = MathHelper.floor_double(this.posZ);
  1211.  
  1212. if (this.worldObj.blockExists(var2, 0, var3))
  1213. {
  1214. double var4 = (this.boundingBox.maxY - this.boundingBox.minY) * 0.66D;
  1215. int var6 = MathHelper.floor_double(this.posY - (double)this.yOffset + var4);
  1216. return this.worldObj.getLightBrightness(var2, var6, var3);
  1217. }
  1218. else
  1219. {
  1220. return 0.0F;
  1221. }
  1222. }
  1223.  
  1224. /**
  1225. * Sets the reference to the World object.
  1226. */
  1227. public void setWorld(World par1World)
  1228. {
  1229. this.worldObj = par1World;
  1230. }
  1231.  
  1232. /**
  1233. * Sets the entity's position and rotation. Args: posX, posY, posZ, yaw, pitch
  1234. */
  1235. public void setPositionAndRotation(double par1, double par3, double par5, float par7, float par8)
  1236. {
  1237. this.prevPosX = this.posX = par1;
  1238. this.prevPosY = this.posY = par3;
  1239. this.prevPosZ = this.posZ = par5;
  1240. this.prevRotationYaw = this.rotationYaw = par7;
  1241. this.prevRotationPitch = this.rotationPitch = par8;
  1242. this.ySize = 0.0F;
  1243. double var9 = (double)(this.prevRotationYaw - par7);
  1244.  
  1245. if (var9 < -180.0D)
  1246. {
  1247. this.prevRotationYaw += 360.0F;
  1248. }
  1249.  
  1250. if (var9 >= 180.0D)
  1251. {
  1252. this.prevRotationYaw -= 360.0F;
  1253. }
  1254.  
  1255. this.setPosition(this.posX, this.posY, this.posZ);
  1256. this.setRotation(par7, par8);
  1257. }
  1258.  
  1259. /**
  1260. * Sets the location and Yaw/Pitch of an entity in the world
  1261. */
  1262. public void setLocationAndAngles(double par1, double par3, double par5, float par7, float par8)
  1263. {
  1264. this.lastTickPosX = this.prevPosX = this.posX = par1;
  1265. this.lastTickPosY = this.prevPosY = this.posY = par3 + (double)this.yOffset;
  1266. this.lastTickPosZ = this.prevPosZ = this.posZ = par5;
  1267. this.rotationYaw = par7;
  1268. this.rotationPitch = par8;
  1269. this.setPosition(this.posX, this.posY, this.posZ);
  1270. }
  1271.  
  1272. /**
  1273. * Returns the distance to the entity. Args: entity
  1274. */
  1275. public float getDistanceToEntity(Entity par1Entity)
  1276. {
  1277. float var2 = (float)(this.posX - par1Entity.posX);
  1278. float var3 = (float)(this.posY - par1Entity.posY);
  1279. float var4 = (float)(this.posZ - par1Entity.posZ);
  1280. return MathHelper.sqrt_float(var2 * var2 + var3 * var3 + var4 * var4);
  1281. }
  1282.  
  1283. /**
  1284. * Gets the squared distance to the position. Args: x, y, z
  1285. */
  1286. public double getDistanceSq(double par1, double par3, double par5)
  1287. {
  1288. double var7 = this.posX - par1;
  1289. double var9 = this.posY - par3;
  1290. double var11 = this.posZ - par5;
  1291. return var7 * var7 + var9 * var9 + var11 * var11;
  1292. }
  1293.  
  1294. /**
  1295. * Gets the distance to the position. Args: x, y, z
  1296. */
  1297. public double getDistance(double par1, double par3, double par5)
  1298. {
  1299. double var7 = this.posX - par1;
  1300. double var9 = this.posY - par3;
  1301. double var11 = this.posZ - par5;
  1302. return (double)MathHelper.sqrt_double(var7 * var7 + var9 * var9 + var11 * var11);
  1303. }
  1304.  
  1305. /**
  1306. * Returns the squared distance to the entity. Args: entity
  1307. */
  1308. public double getDistanceSqToEntity(Entity par1Entity)
  1309. {
  1310. double var2 = this.posX - par1Entity.posX;
  1311. double var4 = this.posY - par1Entity.posY;
  1312. double var6 = this.posZ - par1Entity.posZ;
  1313. return var2 * var2 + var4 * var4 + var6 * var6;
  1314. }
  1315.  
  1316. /**
  1317. * Called by a player entity when they collide with an entity
  1318. */
  1319. public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) {}
  1320.  
  1321. /**
  1322. * Applies a velocity to each of the entities pushing them away from each other. Args: entity
  1323. */
  1324. public void applyEntityCollision(Entity par1Entity)
  1325. {
  1326. if (par1Entity.riddenByEntity != this && par1Entity.ridingEntity != this)
  1327. {
  1328. double var2 = par1Entity.posX - this.posX;
  1329. double var4 = par1Entity.posZ - this.posZ;
  1330. double var6 = MathHelper.abs_max(var2, var4);
  1331.  
  1332. if (var6 >= 0.009999999776482582D)
  1333. {
  1334. var6 = (double)MathHelper.sqrt_double(var6);
  1335. var2 /= var6;
  1336. var4 /= var6;
  1337. double var8 = 1.0D / var6;
  1338.  
  1339. if (var8 > 1.0D)
  1340. {
  1341. var8 = 1.0D;
  1342. }
  1343.  
  1344. var2 *= var8;
  1345. var4 *= var8;
  1346. var2 *= 0.05000000074505806D;
  1347. var4 *= 0.05000000074505806D;
  1348. var2 *= (double)(1.0F - this.entityCollisionReduction);
  1349. var4 *= (double)(1.0F - this.entityCollisionReduction);
  1350. this.addVelocity(-var2, 0.0D, -var4);
  1351. par1Entity.addVelocity(var2, 0.0D, var4);
  1352. }
  1353. }
  1354. }
  1355.  
  1356. /**
  1357. * Adds to the current velocity of the entity. Args: x, y, z
  1358. */
  1359. public void addVelocity(double par1, double par3, double par5)
  1360. {
  1361. this.motionX += par1;
  1362. this.motionY += par3;
  1363. this.motionZ += par5;
  1364. this.isAirBorne = true;
  1365. }
  1366.  
  1367. /**
  1368. * Sets that this entity has been attacked.
  1369. */
  1370. protected void setBeenAttacked()
  1371. {
  1372. this.velocityChanged = true;
  1373. }
  1374.  
  1375. /**
  1376. * Called when the entity is attacked.
  1377. */
  1378. public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
  1379. {
  1380. if (this.isEntityInvulnerable())
  1381. {
  1382. return false;
  1383. }
  1384. else
  1385. {
  1386. this.setBeenAttacked();
  1387. return false;
  1388. }
  1389. }
  1390.  
  1391. /**
  1392. * Returns true if other Entities should be prevented from moving through this Entity.
  1393. */
  1394. public boolean canBeCollidedWith()
  1395. {
  1396. return false;
  1397. }
  1398.  
  1399. /**
  1400. * Returns true if this entity should push and be pushed by other entities when colliding.
  1401. */
  1402. public boolean canBePushed()
  1403. {
  1404. return false;
  1405. }
  1406.  
  1407. /**
  1408. * Adds a value to the player score. Currently not actually used and the entity passed in does nothing. Args:
  1409. * entity, scoreToAdd
  1410. */
  1411. public void addToPlayerScore(Entity par1Entity, int par2) {}
  1412.  
  1413. /**
  1414. * Checks using a Vec3d to determine if this entity is within range of that vector to be rendered. Args: vec3D
  1415. */
  1416. public boolean isInRangeToRenderVec3D(Vec3 par1Vec3)
  1417. {
  1418. double var2 = this.posX - par1Vec3.xCoord;
  1419. double var4 = this.posY - par1Vec3.yCoord;
  1420. double var6 = this.posZ - par1Vec3.zCoord;
  1421. double var8 = var2 * var2 + var4 * var4 + var6 * var6;
  1422. return this.isInRangeToRenderDist(var8);
  1423. }
  1424.  
  1425. /**
  1426. * Checks if the entity is in range to render by using the past in distance and comparing it to its average edge
  1427. * length * 64 * renderDistanceWeight Args: distance
  1428. */
  1429. public boolean isInRangeToRenderDist(double par1)
  1430. {
  1431. double var3 = this.boundingBox.getAverageEdgeLength();
  1432. var3 *= 64.0D * this.renderDistanceWeight;
  1433. return par1 < var3 * var3;
  1434. }
  1435.  
  1436. /**
  1437. * Returns the texture's file path as a String.
  1438. */
  1439. public String getTexture()
  1440. {
  1441. return null;
  1442. }
  1443.  
  1444. public boolean addNotRiddenEntityID(NBTTagCompound par1NBTTagCompound)
  1445. {
  1446. String var2 = this.getEntityString();
  1447.  
  1448. if (!this.isDead && var2 != null)
  1449. {
  1450. par1NBTTagCompound.setString("id", var2);
  1451. this.writeToNBT(par1NBTTagCompound);
  1452. return true;
  1453. }
  1454. else
  1455. {
  1456. return false;
  1457. }
  1458. }
  1459.  
  1460. /**
  1461. * adds the ID of this entity to the NBT given
  1462. */
  1463. public boolean addEntityID(NBTTagCompound par1NBTTagCompound)
  1464. {
  1465. String var2 = this.getEntityString();
  1466.  
  1467. if (!this.isDead && var2 != null && this.riddenByEntity == null)
  1468. {
  1469. par1NBTTagCompound.setString("id", var2);
  1470. this.writeToNBT(par1NBTTagCompound);
  1471. return true;
  1472. }
  1473. else
  1474. {
  1475. return false;
  1476. }
  1477. }
  1478.  
  1479. /**
  1480. * Save the entity to NBT (calls an abstract helper method to write extra data)
  1481. */
  1482. public void writeToNBT(NBTTagCompound par1NBTTagCompound)
  1483. {
  1484. try
  1485. {
  1486. par1NBTTagCompound.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ}));
  1487. par1NBTTagCompound.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
  1488. par1NBTTagCompound.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch}));
  1489. par1NBTTagCompound.setFloat("FallDistance", this.fallDistance);
  1490. par1NBTTagCompound.setShort("Fire", (short)this.fire);
  1491. par1NBTTagCompound.setShort("Air", (short)this.getAir());
  1492. par1NBTTagCompound.setBoolean("OnGround", this.onGround);
  1493. par1NBTTagCompound.setInteger("Dimension", this.dimension);
  1494. par1NBTTagCompound.setBoolean("Invulnerable", this.invulnerable);
  1495. par1NBTTagCompound.setInteger("PortalCooldown", this.timeUntilPortal);
  1496. par1NBTTagCompound.setLong("UUIDMost", this.entityUniqueID.getMostSignificantBits());
  1497. par1NBTTagCompound.setLong("UUIDLeast", this.entityUniqueID.getLeastSignificantBits());
  1498. this.writeEntityToNBT(par1NBTTagCompound);
  1499.  
  1500. if (this.ridingEntity != null)
  1501. {
  1502. NBTTagCompound var2 = new NBTTagCompound("Riding");
  1503.  
  1504. if (this.ridingEntity.addNotRiddenEntityID(var2))
  1505. {
  1506. par1NBTTagCompound.setTag("Riding", var2);
  1507. }
  1508. }
  1509. }
  1510. catch (Throwable var5)
  1511. {
  1512. CrashReport var3 = CrashReport.makeCrashReport(var5, "Saving entity NBT");
  1513. CrashReportCategory var4 = var3.makeCategory("Entity being saved");
  1514. this.func_85029_a(var4);
  1515. throw new ReportedException(var3);
  1516. }
  1517. }
  1518.  
  1519. /**
  1520. * Reads the entity from NBT (calls an abstract helper method to read specialized data)
  1521. */
  1522. public void readFromNBT(NBTTagCompound par1NBTTagCompound)
  1523. {
  1524. try
  1525. {
  1526. NBTTagList var2 = par1NBTTagCompound.getTagList("Pos");
  1527. NBTTagList var6 = par1NBTTagCompound.getTagList("Motion");
  1528. NBTTagList var7 = par1NBTTagCompound.getTagList("Rotation");
  1529. this.motionX = ((NBTTagDouble)var6.tagAt(0)).data;
  1530. this.motionY = ((NBTTagDouble)var6.tagAt(1)).data;
  1531. this.motionZ = ((NBTTagDouble)var6.tagAt(2)).data;
  1532.  
  1533. if (Math.abs(this.motionX) > 10.0D)
  1534. {
  1535. this.motionX = 0.0D;
  1536. }
  1537.  
  1538. if (Math.abs(this.motionY) > 10.0D)
  1539. {
  1540. this.motionY = 0.0D;
  1541. }
  1542.  
  1543. if (Math.abs(this.motionZ) > 10.0D)
  1544. {
  1545. this.motionZ = 0.0D;
  1546. }
  1547.  
  1548. this.prevPosX = this.lastTickPosX = this.posX = ((NBTTagDouble)var2.tagAt(0)).data;
  1549. this.prevPosY = this.lastTickPosY = this.posY = ((NBTTagDouble)var2.tagAt(1)).data;
  1550. this.prevPosZ = this.lastTickPosZ = this.posZ = ((NBTTagDouble)var2.tagAt(2)).data;
  1551. this.prevRotationYaw = this.rotationYaw = ((NBTTagFloat)var7.tagAt(0)).data;
  1552. this.prevRotationPitch = this.rotationPitch = ((NBTTagFloat)var7.tagAt(1)).data;
  1553. this.fallDistance = par1NBTTagCompound.getFloat("FallDistance");
  1554. this.fire = par1NBTTagCompound.getShort("Fire");
  1555. this.setAir(par1NBTTagCompound.getShort("Air"));
  1556. this.onGround = par1NBTTagCompound.getBoolean("OnGround");
  1557. this.dimension = par1NBTTagCompound.getInteger("Dimension");
  1558. this.invulnerable = par1NBTTagCompound.getBoolean("Invulnerable");
  1559. this.timeUntilPortal = par1NBTTagCompound.getInteger("PortalCooldown");
  1560.  
  1561. if (par1NBTTagCompound.hasKey("UUIDMost") && par1NBTTagCompound.hasKey("UUIDLeast"))
  1562. {
  1563. this.entityUniqueID = new UUID(par1NBTTagCompound.getLong("UUIDMost"), par1NBTTagCompound.getLong("UUIDLeast"));
  1564. }
  1565.  
  1566. this.setPosition(this.posX, this.posY, this.posZ);
  1567. this.setRotation(this.rotationYaw, this.rotationPitch);
  1568. this.readEntityFromNBT(par1NBTTagCompound);
  1569. }
  1570. catch (Throwable var5)
  1571. {
  1572. CrashReport var3 = CrashReport.makeCrashReport(var5, "Loading entity NBT");
  1573. CrashReportCategory var4 = var3.makeCategory("Entity being loaded");
  1574. this.func_85029_a(var4);
  1575. throw new ReportedException(var3);
  1576. }
  1577. }
  1578.  
  1579. /**
  1580. * Returns the string that identifies this Entity's class
  1581. */
  1582. protected final String getEntityString()
  1583. {
  1584. return EntityList.getEntityString(this);
  1585. }
  1586.  
  1587. /**
  1588. * (abstract) Protected helper method to read subclass entity data from NBT.
  1589. */
  1590. protected abstract void readEntityFromNBT(NBTTagCompound var1);
  1591.  
  1592. /**
  1593. * (abstract) Protected helper method to write subclass entity data to NBT.
  1594. */
  1595. protected abstract void writeEntityToNBT(NBTTagCompound var1);
  1596.  
  1597. /**
  1598. * creates a NBT list from the array of doubles passed to this function
  1599. */
  1600. protected NBTTagList newDoubleNBTList(double ... par1ArrayOfDouble)
  1601. {
  1602. NBTTagList var2 = new NBTTagList();
  1603. double[] var3 = par1ArrayOfDouble;
  1604. int var4 = par1ArrayOfDouble.length;
  1605.  
  1606. for (int var5 = 0; var5 < var4; ++var5)
  1607. {
  1608. double var6 = var3[var5];
  1609. var2.appendTag(new NBTTagDouble((String)null, var6));
  1610. }
  1611.  
  1612. return var2;
  1613. }
  1614.  
  1615. /**
  1616. * Returns a new NBTTagList filled with the specified floats
  1617. */
  1618. protected NBTTagList newFloatNBTList(float ... par1ArrayOfFloat)
  1619. {
  1620. NBTTagList var2 = new NBTTagList();
  1621. float[] var3 = par1ArrayOfFloat;
  1622. int var4 = par1ArrayOfFloat.length;
  1623.  
  1624. for (int var5 = 0; var5 < var4; ++var5)
  1625. {
  1626. float var6 = var3[var5];
  1627. var2.appendTag(new NBTTagFloat((String)null, var6));
  1628. }
  1629.  
  1630. return var2;
  1631. }
  1632.  
  1633. public float getShadowSize()
  1634. {
  1635. return this.height / 2.0F;
  1636. }
  1637.  
  1638. /**
  1639. * Drops an item stack at the entity's position. Args: itemID, count
  1640. */
  1641. public EntityItem dropItem(int par1, int par2)
  1642. {
  1643. return this.dropItemWithOffset(par1, par2, 0.0F);
  1644. }
  1645.  
  1646. /**
  1647. * Drops an item stack with a specified y offset. Args: itemID, count, yOffset
  1648. */
  1649. public EntityItem dropItemWithOffset(int par1, int par2, float par3)
  1650. {
  1651. return this.entityDropItem(new ItemStack(par1, par2, 0), par3);
  1652. }
  1653.  
  1654. /**
  1655. * Drops an item at the position of the entity.
  1656. */
  1657. public EntityItem entityDropItem(ItemStack par1ItemStack, float par2)
  1658. {
  1659. EntityItem var3 = new EntityItem(this.worldObj, this.posX, this.posY + (double)par2, this.posZ, par1ItemStack);
  1660. var3.delayBeforeCanPickup = 10;
  1661. this.worldObj.spawnEntityInWorld(var3);
  1662. return var3;
  1663. }
  1664.  
  1665. /**
  1666. * Checks whether target entity is alive.
  1667. */
  1668. public boolean isEntityAlive()
  1669. {
  1670. return !this.isDead;
  1671. }
  1672.  
  1673. /**
  1674. * Checks if this entity is inside of an opaque block
  1675. */
  1676. public boolean isEntityInsideOpaqueBlock()
  1677. {
  1678. for (int var1 = 0; var1 < 8; ++var1)
  1679. {
  1680. float var2 = ((float)((var1 >> 0) % 2) - 0.5F) * this.width * 0.8F;
  1681. float var3 = ((float)((var1 >> 1) % 2) - 0.5F) * 0.1F;
  1682. float var4 = ((float)((var1 >> 2) % 2) - 0.5F) * this.width * 0.8F;
  1683. int var5 = MathHelper.floor_double(this.posX + (double)var2);
  1684. int var6 = MathHelper.floor_double(this.posY + (double)this.getEyeHeight() + (double)var3);
  1685. int var7 = MathHelper.floor_double(this.posZ + (double)var4);
  1686.  
  1687. if (this.worldObj.isBlockNormalCube(var5, var6, var7))
  1688. {
  1689. return true;
  1690. }
  1691. }
  1692.  
  1693. return false;
  1694. }
  1695.  
  1696. /**
  1697. * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
  1698. */
  1699. public boolean interact(EntityPlayer par1EntityPlayer)
  1700. {
  1701. return false;
  1702. }
  1703.  
  1704. /**
  1705. * Returns a boundingBox used to collide the entity with other entities and blocks. This enables the entity to be
  1706. * pushable on contact, like boats or minecarts.
  1707. */
  1708. public AxisAlignedBB getCollisionBox(Entity par1Entity)
  1709. {
  1710. return null;
  1711. }
  1712.  
  1713. /**
  1714. * Handles updating while being ridden by an entity
  1715. */
  1716. public void updateRidden()
  1717. {
  1718. if (this.ridingEntity.isDead)
  1719. {
  1720. this.ridingEntity = null;
  1721. }
  1722. else
  1723. {
  1724. this.motionX = 0.0D;
  1725. this.motionY = 0.0D;
  1726. this.motionZ = 0.0D;
  1727. this.onUpdate();
  1728.  
  1729. if (this.ridingEntity != null)
  1730. {
  1731. this.ridingEntity.updateRiderPosition();
  1732. this.entityRiderYawDelta += (double)(this.ridingEntity.rotationYaw - this.ridingEntity.prevRotationYaw);
  1733.  
  1734. for (this.entityRiderPitchDelta += (double)(this.ridingEntity.rotationPitch - this.ridingEntity.prevRotationPitch); this.entityRiderYawDelta >= 180.0D; this.entityRiderYawDelta -= 360.0D)
  1735. {
  1736. ;
  1737. }
  1738.  
  1739. while (this.entityRiderYawDelta < -180.0D)
  1740. {
  1741. this.entityRiderYawDelta += 360.0D;
  1742. }
  1743.  
  1744. while (this.entityRiderPitchDelta >= 180.0D)
  1745. {
  1746. this.entityRiderPitchDelta -= 360.0D;
  1747. }
  1748.  
  1749. while (this.entityRiderPitchDelta < -180.0D)
  1750. {
  1751. this.entityRiderPitchDelta += 360.0D;
  1752. }
  1753.  
  1754. double var1 = this.entityRiderYawDelta * 0.5D;
  1755. double var3 = this.entityRiderPitchDelta * 0.5D;
  1756. float var5 = 10.0F;
  1757.  
  1758. if (var1 > (double)var5)
  1759. {
  1760. var1 = (double)var5;
  1761. }
  1762.  
  1763. if (var1 < (double)(-var5))
  1764. {
  1765. var1 = (double)(-var5);
  1766. }
  1767.  
  1768. if (var3 > (double)var5)
  1769. {
  1770. var3 = (double)var5;
  1771. }
  1772.  
  1773. if (var3 < (double)(-var5))
  1774. {
  1775. var3 = (double)(-var5);
  1776. }
  1777.  
  1778. this.entityRiderYawDelta -= var1;
  1779. this.entityRiderPitchDelta -= var3;
  1780. this.rotationYaw = (float)((double)this.rotationYaw + var1);
  1781. this.rotationPitch = (float)((double)this.rotationPitch + var3);
  1782. }
  1783. }
  1784. }
  1785.  
  1786. public void updateRiderPosition()
  1787. {
  1788. if (this.riddenByEntity != null)
  1789. {
  1790. if (!(this.riddenByEntity instanceof EntityPlayer) || !((EntityPlayer)this.riddenByEntity).func_71066_bF())
  1791. {
  1792. this.riddenByEntity.lastTickPosX = this.lastTickPosX;
  1793. this.riddenByEntity.lastTickPosY = this.lastTickPosY + this.getMountedYOffset() + this.riddenByEntity.getYOffset();
  1794. this.riddenByEntity.lastTickPosZ = this.lastTickPosZ;
  1795. }
  1796.  
  1797. this.riddenByEntity.setPosition(this.posX, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ);
  1798. }
  1799. }
  1800.  
  1801. /**
  1802. * Returns the Y Offset of this entity.
  1803. */
  1804. public double getYOffset()
  1805. {
  1806. return (double)this.yOffset;
  1807. }
  1808.  
  1809. /**
  1810. * Returns the Y offset from the entity's position for any entity riding this one.
  1811. */
  1812. public double getMountedYOffset()
  1813. {
  1814. return (double)this.height * 0.75D;
  1815. }
  1816.  
  1817. /**
  1818. * Called when a player mounts an entity. e.g. mounts a pig, mounts a boat.
  1819. */
  1820. public void mountEntity(Entity par1Entity)
  1821. {
  1822. this.entityRiderPitchDelta = 0.0D;
  1823. this.entityRiderYawDelta = 0.0D;
  1824.  
  1825. if (par1Entity == null)
  1826. {
  1827. if (this.ridingEntity != null)
  1828. {
  1829. this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch);
  1830. this.ridingEntity.riddenByEntity = null;
  1831. }
  1832.  
  1833. this.ridingEntity = null;
  1834. }
  1835. else
  1836. {
  1837. if (this.ridingEntity != null)
  1838. {
  1839. this.ridingEntity.riddenByEntity = null;
  1840. }
  1841.  
  1842. this.ridingEntity = par1Entity;
  1843. par1Entity.riddenByEntity = this;
  1844. }
  1845. }
  1846.  
  1847. /**
  1848. * Called when a player unounts an entity.
  1849. */
  1850. public void unmountEntity(Entity par1Entity)
  1851. {
  1852. double var2 = this.posX;
  1853. double var4 = this.posY;
  1854. double var6 = this.posZ;
  1855.  
  1856. if (par1Entity != null)
  1857. {
  1858. var2 = par1Entity.posX;
  1859. var4 = par1Entity.boundingBox.minY + (double)par1Entity.height;
  1860. var6 = par1Entity.posZ;
  1861. }
  1862.  
  1863. for (double var8 = -1.5D; var8 < 2.0D; ++var8)
  1864. {
  1865. for (double var10 = -1.5D; var10 < 2.0D; ++var10)
  1866. {
  1867. if (var8 != 0.0D || var10 != 0.0D)
  1868. {
  1869. int var12 = (int)(this.posX + var8);
  1870. int var13 = (int)(this.posZ + var10);
  1871. AxisAlignedBB var14 = this.boundingBox.getOffsetBoundingBox(var8, 1.0D, var10);
  1872.  
  1873. if (this.worldObj.getCollidingBlockBounds(var14).isEmpty())
  1874. {
  1875. if (this.worldObj.doesBlockHaveSolidTopSurface(var12, (int)this.posY, var13))
  1876. {
  1877. this.setLocationAndAngles(this.posX + var8, this.posY + 1.0D, this.posZ + var10, this.rotationYaw, this.rotationPitch);
  1878. return;
  1879. }
  1880.  
  1881. if (this.worldObj.doesBlockHaveSolidTopSurface(var12, (int)this.posY - 1, var13) || this.worldObj.getBlockMaterial(var12, (int)this.posY - 1, var13) == Material.water)
  1882. {
  1883. var2 = this.posX + var8;
  1884. var4 = this.posY + 1.0D;
  1885. var6 = this.posZ + var10;
  1886. }
  1887. }
  1888. }
  1889. }
  1890. }
  1891.  
  1892. this.setLocationAndAngles(var2, var4, var6, this.rotationYaw, this.rotationPitch);
  1893. }
  1894.  
  1895. /**
  1896. * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
  1897. * posY, posZ, yaw, pitch
  1898. */
  1899. public void setPositionAndRotation2(double par1, double par3, double par5, float par7, float par8, int par9)
  1900. {
  1901. this.setPosition(par1, par3, par5);
  1902. this.setRotation(par7, par8);
  1903. List var10 = this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox.contract(0.03125D, 0.0D, 0.03125D));
  1904.  
  1905. if (!var10.isEmpty())
  1906. {
  1907. double var11 = 0.0D;
  1908.  
  1909. for (int var13 = 0; var13 < var10.size(); ++var13)
  1910. {
  1911. AxisAlignedBB var14 = (AxisAlignedBB)var10.get(var13);
  1912.  
  1913. if (var14.maxY > var11)
  1914. {
  1915. var11 = var14.maxY;
  1916. }
  1917. }
  1918.  
  1919. par3 += var11 - this.boundingBox.minY;
  1920. this.setPosition(par1, par3, par5);
  1921. }
  1922. }
  1923.  
  1924. public float getCollisionBorderSize()
  1925. {
  1926. return 0.1F;
  1927. }
  1928.  
  1929. /**
  1930. * returns a (normalized) vector of where this entity is looking
  1931. */
  1932. public Vec3 getLookVec()
  1933. {
  1934. return null;
  1935. }
  1936.  
  1937. /**
  1938. * Called by portal blocks when an entity is within it.
  1939. */
  1940. public void setInPortal()
  1941. {
  1942. if (this.timeUntilPortal > 0)
  1943. {
  1944. this.timeUntilPortal = this.getPortalCooldown();
  1945. }
  1946. else
  1947. {
  1948. double var1 = this.prevPosX - this.posX;
  1949. double var3 = this.prevPosZ - this.posZ;
  1950.  
  1951. if (!this.worldObj.isRemote && !this.inPortal)
  1952. {
  1953. this.teleportDirection = Direction.getMovementDirection(var1, var3);
  1954. }
  1955.  
  1956. this.inPortal = true;
  1957. }
  1958. }
  1959.  
  1960. /**
  1961. * Return the amount of cooldown before this entity can use a portal again.
  1962. */
  1963. public int getPortalCooldown()
  1964. {
  1965. return 900;
  1966. }
  1967.  
  1968. /**
  1969. * Sets the velocity to the args. Args: x, y, z
  1970. */
  1971. public void setVelocity(double par1, double par3, double par5)
  1972. {
  1973. this.motionX = par1;
  1974. this.motionY = par3;
  1975. this.motionZ = par5;
  1976. }
  1977.  
  1978. public void handleHealthUpdate(byte par1) {}
  1979.  
  1980. /**
  1981. * Setups the entity to do the hurt animation. Only used by packets in multiplayer.
  1982. */
  1983. public void performHurtAnimation() {}
  1984.  
  1985. public void updateCloak()
  1986. {
  1987. }
  1988.  
  1989. public ItemStack[] getLastActiveItems()
  1990. {
  1991. return null;
  1992. }
  1993.  
  1994. /**
  1995. * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
  1996. */
  1997. public void setCurrentItemOrArmor(int par1, ItemStack par2ItemStack) {}
  1998.  
  1999. /**
  2000. * Returns true if the entity is on fire. Used by render to add the fire effect on rendering.
  2001. */
  2002. public boolean isBurning()
  2003. {
  2004. return this.fire > 0 || this.getFlag(0);
  2005. }
  2006.  
  2007. /**
  2008. * Returns true if the entity is riding another entity, used by render to rotate the legs to be in 'sit' position
  2009. * for players.
  2010. */
  2011. public boolean isRiding()
  2012. {
  2013. return this.ridingEntity != null || this.getFlag(2);
  2014. }
  2015.  
  2016. /**
  2017. * Returns if this entity is sneaking.
  2018. */
  2019. public boolean isSneaking()
  2020. {
  2021. return this.getFlag(1);
  2022. }
  2023.  
  2024. /**
  2025. * Sets the sneaking flag.
  2026. */
  2027. public void setSneaking(boolean par1)
  2028. {
  2029. this.setFlag(1, par1);
  2030. }
  2031.  
  2032. /**
  2033. * Get if the Entity is sprinting.
  2034. */
  2035. public boolean isSprinting()
  2036. {
  2037. return this.getFlag(3);
  2038. }
  2039.  
  2040. /**
  2041. * Set sprinting switch for Entity.
  2042. */
  2043. public void setSprinting(boolean par1)
  2044. {
  2045. this.setFlag(3, par1);
  2046. }
  2047.  
  2048. public boolean isInvisible()
  2049. {
  2050. return this.getFlag(5);
  2051. }
  2052.  
  2053. public boolean func_98034_c(EntityPlayer par1EntityPlayer)
  2054. {
  2055. return this.isInvisible();
  2056. }
  2057.  
  2058. public void setInvisible(boolean par1)
  2059. {
  2060. this.setFlag(5, par1);
  2061. }
  2062.  
  2063. public boolean isEating()
  2064. {
  2065. return this.getFlag(4);
  2066. }
  2067.  
  2068. public void setEating(boolean par1)
  2069. {
  2070. this.setFlag(4, par1);
  2071. }
  2072.  
  2073. /**
  2074. * Returns true if the flag is active for the entity. Known flags: 0) is burning; 1) is sneaking; 2) is riding
  2075. * something; 3) is sprinting; 4) is eating
  2076. */
  2077. protected boolean getFlag(int par1)
  2078. {
  2079. return (this.dataWatcher.getWatchableObjectByte(0) & 1 << par1) != 0;
  2080. }
  2081.  
  2082. /**
  2083. * Enable or disable a entity flag, see getEntityFlag to read the know flags.
  2084. */
  2085. protected void setFlag(int par1, boolean par2)
  2086. {
  2087. byte var3 = this.dataWatcher.getWatchableObjectByte(0);
  2088.  
  2089. if (par2)
  2090. {
  2091. this.dataWatcher.updateObject(0, Byte.valueOf((byte)(var3 | 1 << par1)));
  2092. }
  2093. else
  2094. {
  2095. this.dataWatcher.updateObject(0, Byte.valueOf((byte)(var3 & ~(1 << par1))));
  2096. }
  2097. }
  2098.  
  2099. public int getAir()
  2100. {
  2101. return this.dataWatcher.getWatchableObjectShort(1);
  2102. }
  2103.  
  2104. public void setAir(int par1)
  2105. {
  2106. this.dataWatcher.updateObject(1, Short.valueOf((short)par1));
  2107. }
  2108.  
  2109. /**
  2110. * Called when a lightning bolt hits the entity.
  2111. */
  2112. public void onStruckByLightning(EntityLightningBolt par1EntityLightningBolt)
  2113. {
  2114. this.dealFireDamage(5);
  2115. ++this.fire;
  2116.  
  2117. if (this.fire == 0)
  2118. {
  2119. this.setFire(8);
  2120. }
  2121. }
  2122.  
  2123. /**
  2124. * This method gets called when the entity kills another one.
  2125. */
  2126. public void onKillEntity(EntityLiving par1EntityLiving) {}
  2127.  
  2128. /**
  2129. * Adds velocity to push the entity out of blocks at the specified x, y, z position Args: x, y, z
  2130. */
  2131. protected boolean pushOutOfBlocks(double par1, double par3, double par5)
  2132. {
  2133. int var7 = MathHelper.floor_double(par1);
  2134. int var8 = MathHelper.floor_double(par3);
  2135. int var9 = MathHelper.floor_double(par5);
  2136. double var10 = par1 - (double)var7;
  2137. double var12 = par3 - (double)var8;
  2138. double var14 = par5 - (double)var9;
  2139. List var16 = this.worldObj.getCollidingBlockBounds(this.boundingBox);
  2140.  
  2141. if (var16.isEmpty() && !this.worldObj.func_85174_u(var7, var8, var9))
  2142. {
  2143. return false;
  2144. }
  2145. else
  2146. {
  2147. boolean var17 = !this.worldObj.func_85174_u(var7 - 1, var8, var9);
  2148. boolean var18 = !this.worldObj.func_85174_u(var7 + 1, var8, var9);
  2149. boolean var19 = !this.worldObj.func_85174_u(var7, var8 - 1, var9);
  2150. boolean var20 = !this.worldObj.func_85174_u(var7, var8 + 1, var9);
  2151. boolean var21 = !this.worldObj.func_85174_u(var7, var8, var9 - 1);
  2152. boolean var22 = !this.worldObj.func_85174_u(var7, var8, var9 + 1);
  2153. byte var23 = 3;
  2154. double var24 = 9999.0D;
  2155.  
  2156. if (var17 && var10 < var24)
  2157. {
  2158. var24 = var10;
  2159. var23 = 0;
  2160. }
  2161.  
  2162. if (var18 && 1.0D - var10 < var24)
  2163. {
  2164. var24 = 1.0D - var10;
  2165. var23 = 1;
  2166. }
  2167.  
  2168. if (var20 && 1.0D - var12 < var24)
  2169. {
  2170. var24 = 1.0D - var12;
  2171. var23 = 3;
  2172. }
  2173.  
  2174. if (var21 && var14 < var24)
  2175. {
  2176. var24 = var14;
  2177. var23 = 4;
  2178. }
  2179.  
  2180. if (var22 && 1.0D - var14 < var24)
  2181. {
  2182. var24 = 1.0D - var14;
  2183. var23 = 5;
  2184. }
  2185.  
  2186. float var26 = this.rand.nextFloat() * 0.2F + 0.1F;
  2187.  
  2188. if (var23 == 0)
  2189. {
  2190. this.motionX = (double)(-var26);
  2191. }
  2192.  
  2193. if (var23 == 1)
  2194. {
  2195. this.motionX = (double)var26;
  2196. }
  2197.  
  2198. if (var23 == 2)
  2199. {
  2200. this.motionY = (double)(-var26);
  2201. }
  2202.  
  2203. if (var23 == 3)
  2204. {
  2205. this.motionY = (double)var26;
  2206. }
  2207.  
  2208. if (var23 == 4)
  2209. {
  2210. this.motionZ = (double)(-var26);
  2211. }
  2212.  
  2213. if (var23 == 5)
  2214. {
  2215. this.motionZ = (double)var26;
  2216. }
  2217.  
  2218. return true;
  2219. }
  2220. }
  2221.  
  2222. /**
  2223. * Sets the Entity inside a web block.
  2224. */
  2225. public void setInWeb()
  2226. {
  2227. this.isInWeb = true;
  2228. this.fallDistance = 0.0F;
  2229. }
  2230.  
  2231. /**
  2232. * Gets the username of the entity.
  2233. */
  2234. public String getEntityName()
  2235. {
  2236. String var1 = EntityList.getEntityString(this);
  2237.  
  2238. if (var1 == null)
  2239. {
  2240. var1 = "generic";
  2241. }
  2242.  
  2243. return StatCollector.translateToLocal("entity." + var1 + ".name");
  2244. }
  2245.  
  2246. /**
  2247. * Return the Entity parts making up this Entity (currently only for dragons)
  2248. */
  2249. public Entity[] getParts()
  2250. {
  2251. return null;
  2252. }
  2253.  
  2254. /**
  2255. * Returns true if Entity argument is equal to this Entity
  2256. */
  2257. public boolean isEntityEqual(Entity par1Entity)
  2258. {
  2259. return this == par1Entity;
  2260. }
  2261.  
  2262. public float getRotationYawHead()
  2263. {
  2264. return 0.0F;
  2265. }
  2266.  
  2267. /**
  2268. * Sets the head's yaw rotation of the entity.
  2269. */
  2270. public void setRotationYawHead(float par1) {}
  2271.  
  2272. /**
  2273. * If returns false, the item will not inflict any damage against entities.
  2274. */
  2275. public boolean canAttackWithItem()
  2276. {
  2277. return true;
  2278. }
  2279.  
  2280. public boolean func_85031_j(Entity par1Entity)
  2281. {
  2282. return false;
  2283. }
  2284.  
  2285. public String toString()
  2286. {
  2287. return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", new Object[] {this.getClass().getSimpleName(), this.getEntityName(), Integer.valueOf(this.entityId), this.worldObj == null ? "~NULL~" : this.worldObj.getWorldInfo().getWorldName(), Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)});
  2288. }
  2289.  
  2290. /**
  2291. * Return whether this entity is invulnerable to damage.
  2292. */
  2293. public boolean isEntityInvulnerable()
  2294. {
  2295. return this.invulnerable;
  2296. }
  2297.  
  2298. public void func_82149_j(Entity par1Entity)
  2299. {
  2300. this.setLocationAndAngles(par1Entity.posX, par1Entity.posY, par1Entity.posZ, par1Entity.rotationYaw, par1Entity.rotationPitch);
  2301. }
  2302.  
  2303. /**
  2304. * Copies important data from another entity to this entity. Used when teleporting entities between worlds, as this
  2305. * actually deletes the teleporting entity and re-creates it on the other side. Params: Entity to copy from, unused
  2306. * (always true)
  2307. */
  2308. public void copyDataFrom(Entity par1Entity, boolean par2)
  2309. {
  2310. NBTTagCompound var3 = new NBTTagCompound();
  2311. par1Entity.writeToNBT(var3);
  2312. this.readFromNBT(var3);
  2313. this.timeUntilPortal = par1Entity.timeUntilPortal;
  2314. this.teleportDirection = par1Entity.teleportDirection;
  2315. }
  2316.  
  2317. /**
  2318. * Teleports the entity to another dimension. Params: Dimension number to teleport to
  2319. */
  2320. public void travelToDimension(int par1)
  2321. {
  2322. if (!this.worldObj.isRemote && !this.isDead)
  2323. {
  2324. this.worldObj.theProfiler.startSection("changeDimension");
  2325. MinecraftServer var2 = MinecraftServer.getServer();
  2326. int var3 = this.dimension;
  2327. WorldServer var4 = var2.worldServerForDimension(var3);
  2328. WorldServer var5 = var2.worldServerForDimension(par1);
  2329. this.dimension = par1;
  2330. this.worldObj.removeEntity(this);
  2331. this.isDead = false;
  2332. this.worldObj.theProfiler.startSection("reposition");
  2333. var2.getConfigurationManager().transferEntityToWorld(this, var3, var4, var5);
  2334. this.worldObj.theProfiler.endStartSection("reloading");
  2335. Entity var6 = EntityList.createEntityByName(EntityList.getEntityString(this), var5);
  2336.  
  2337. if (var6 != null)
  2338. {
  2339. var6.copyDataFrom(this, true);
  2340. var5.spawnEntityInWorld(var6);
  2341. }
  2342.  
  2343. this.isDead = true;
  2344. this.worldObj.theProfiler.endSection();
  2345. var4.resetUpdateEntityTick();
  2346. var5.resetUpdateEntityTick();
  2347. this.worldObj.theProfiler.endSection();
  2348. }
  2349. }
  2350.  
  2351. public float func_82146_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, Block par6Block)
  2352. {
  2353. return par6Block.getExplosionResistance(this);
  2354. }
  2355.  
  2356. public boolean func_96091_a(Explosion par1Explosion, World par2World, int par3, int par4, int par5, int par6, float par7)
  2357. {
  2358. return true;
  2359. }
  2360.  
  2361. public int func_82143_as()
  2362. {
  2363. return 3;
  2364. }
  2365.  
  2366. public int getTeleportDirection()
  2367. {
  2368. return this.teleportDirection;
  2369. }
  2370.  
  2371. /**
  2372. * Return whether this entity should NOT trigger a pressure plate or a tripwire.
  2373. */
  2374. public boolean doesEntityNotTriggerPressurePlate()
  2375. {
  2376. return false;
  2377. }
  2378.  
  2379. public void func_85029_a(CrashReportCategory par1CrashReportCategory)
  2380. {
  2381. par1CrashReportCategory.addCrashSectionCallable("Entity Type", new CallableEntityType(this));
  2382. par1CrashReportCategory.addCrashSection("Entity ID", Integer.valueOf(this.entityId));
  2383. par1CrashReportCategory.addCrashSectionCallable("Entity Name", new CallableEntityName(this));
  2384. par1CrashReportCategory.addCrashSection("Entity\'s Exact location", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.posX), Double.valueOf(this.posY), Double.valueOf(this.posZ)}));
  2385. par1CrashReportCategory.addCrashSection("Entity\'s Block location", CrashReportCategory.getLocationInfo(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)));
  2386. par1CrashReportCategory.addCrashSection("Entity\'s Momentum", String.format("%.2f, %.2f, %.2f", new Object[] {Double.valueOf(this.motionX), Double.valueOf(this.motionY), Double.valueOf(this.motionZ)}));
  2387. }
  2388.  
  2389. /**
  2390. * Return whether this entity should be rendered as on fire.
  2391. */
  2392. public boolean canRenderOnFire()
  2393. {
  2394. return this.isBurning();
  2395. }
  2396.  
  2397. public boolean func_96092_aw()
  2398. {
  2399. return true;
  2400. }
  2401.  
  2402. /**
  2403. * Returns the translated name of the entity.
  2404. */
  2405. public String getTranslatedEntityName()
  2406. {
  2407. return this.getEntityName();
  2408. }
  2409. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement