Advertisement
Guest User

EntityDiamondDragon

a guest
Jul 30th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.10 KB | None | 0 0
  1. package main.com.blueeyes.dutchangeldragons.entity;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import main.com.blueeyes.dutchangeldragons.item.DecoyDragonItems;
  6. import net.minecraft.block.Block;
  7. import net.minecraft.block.BlockColored;
  8. import net.minecraft.entity.Entity;
  9. import net.minecraft.entity.EntityAgeable;
  10. import net.minecraft.entity.EntityLivingBase;
  11. import net.minecraft.entity.SharedMonsterAttributes;
  12. import net.minecraft.entity.ai.EntityAIAttackOnCollide;
  13. import net.minecraft.entity.ai.EntityAIBeg;
  14. import net.minecraft.entity.ai.EntityAIFollowOwner;
  15. import net.minecraft.entity.ai.EntityAIHurtByTarget;
  16. import net.minecraft.entity.ai.EntityAILeapAtTarget;
  17. import net.minecraft.entity.ai.EntityAILookIdle;
  18. import net.minecraft.entity.ai.EntityAIMate;
  19. import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
  20. import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
  21. import net.minecraft.entity.ai.EntityAISwimming;
  22. import net.minecraft.entity.ai.EntityAITargetNonTamed;
  23. import net.minecraft.entity.ai.EntityAITempt;
  24. import net.minecraft.entity.ai.EntityAIWander;
  25. import net.minecraft.entity.ai.EntityAIWatchClosest;
  26. import net.minecraft.entity.monster.EntityCreeper;
  27. import net.minecraft.entity.monster.EntityGhast;
  28. import net.minecraft.entity.passive.EntityAnimal;
  29. import net.minecraft.entity.passive.EntityHorse;
  30. import net.minecraft.entity.passive.EntitySheep;
  31. import net.minecraft.entity.passive.EntityTameable;
  32. import net.minecraft.entity.player.EntityPlayer;
  33. import net.minecraft.entity.projectile.EntityArrow;
  34. import net.minecraft.init.Items;
  35. import net.minecraft.item.Item;
  36. import net.minecraft.item.ItemFood;
  37. import net.minecraft.item.ItemStack;
  38. import net.minecraft.nbt.NBTTagCompound;
  39. import net.minecraft.pathfinding.PathEntity;
  40. import net.minecraft.util.DamageSource;
  41. import net.minecraft.util.MathHelper;
  42. import net.minecraft.world.World;
  43.  
  44. public class EntityDiamondDragon extends EntityTameable
  45. {
  46. private float field_70926_e;
  47. private float field_70924_f;
  48. /** true is the wolf is wet else false */
  49. private boolean isShaking;
  50. private boolean field_70928_h;
  51. /** This time increases while wolf is shaking and emitting water particles. */
  52. private float timeWolfIsShaking;
  53. private float prevTimeWolfIsShaking;
  54. private static final String __OBFID = "CL_00001654";
  55.  
  56. public EntityDiamondDragon(World p_i1696_1_)
  57. {
  58. super(p_i1696_1_);
  59. this.setSize(0.6F, 0.8F);
  60. this.getNavigator().setAvoidsWater(true);
  61. this.tasks.addTask(1, new EntityAISwimming(this));
  62. this.tasks.addTask(2, this.aiSit);
  63. this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
  64. this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
  65. this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
  66. this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
  67. this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  68. this.tasks.addTask(8, new EntityAITempt(this, 1.2D, Items.diamond, false));
  69. this.tasks.addTask(9, new EntityAITempt(this, 1.2D, Items.diamond, false));
  70. this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  71. this.tasks.addTask(11, new EntityAILookIdle(this));
  72. this.isImmuneToFire = true;
  73. this.experienceValue = 10;
  74. this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
  75. this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
  76. this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
  77. this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
  78. this.setTamed(false);
  79. }
  80. public boolean canBreatheUnderwater()
  81. {
  82. return true;
  83. }
  84. protected void applyEntityAttributes()
  85. {
  86. super.applyEntityAttributes();
  87. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5);
  88.  
  89. if (this.isTamed())
  90. {
  91. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(999.0D);
  92. }
  93. else
  94. {
  95. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
  96. }
  97. }
  98.  
  99. /**
  100. * Returns true if the newer Entity AI code should be run
  101. */
  102. public boolean isAIEnabled()
  103. {
  104. return true;
  105. }
  106.  
  107. /**
  108. * Sets the active target the Task system uses for tracking
  109. */
  110. public void setAttackTarget(EntityLivingBase p_70624_1_)
  111. {
  112. super.setAttackTarget(p_70624_1_);
  113.  
  114. if (p_70624_1_ == null)
  115. {
  116. this.setAngry(false);
  117. }
  118. else if (!this.isTamed())
  119. {
  120. this.setAngry(true);
  121. }
  122. }
  123.  
  124. /**
  125. * main AI tick function, replaces updateEntityActionState
  126. */
  127. protected void updateAITick()
  128. {
  129. this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
  130. }
  131.  
  132. protected void entityInit()
  133. {
  134. super.entityInit();
  135. this.dataWatcher.addObject(18, new Float(this.getHealth()));
  136. this.dataWatcher.addObject(19, new Byte((byte)0));
  137. this.dataWatcher.addObject(20, new Byte((byte)BlockColored.func_150032_b(1)));
  138. }
  139.  
  140. protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_)
  141. {
  142. this.playSound("mob.wolf.step", 0.15F, 1.0F);
  143. }
  144.  
  145. /**
  146. * (abstract) Protected helper method to write subclass entity data to NBT.
  147. */
  148. public void writeEntityToNBT(NBTTagCompound p_70014_1_)
  149. {
  150. super.writeEntityToNBT(p_70014_1_);
  151. p_70014_1_.setBoolean("Angry", this.isAngry());
  152. p_70014_1_.setByte("CollarColor", (byte)this.getCollarColor());
  153. }
  154.  
  155. /**
  156. * (abstract) Protected helper method to read subclass entity data from NBT.
  157. */
  158. public void readEntityFromNBT(NBTTagCompound p_70037_1_)
  159. {
  160. super.readEntityFromNBT(p_70037_1_);
  161. this.setAngry(p_70037_1_.getBoolean("Angry"));
  162.  
  163. if (p_70037_1_.hasKey("CollarColor", 99))
  164. {
  165. this.setCollarColor(p_70037_1_.getByte("CollarColor"));
  166. }
  167. }
  168.  
  169. protected void fall(float p_70069_1_) {}
  170. /**
  171. * Returns the sound this mob makes while it's alive.
  172. */
  173. protected String getLivingSound()
  174. {
  175. return this.isAngry() ? "dutchangeldragons:mob.tinydragon.tinydragon" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "dutchangeldragons:mob.tinydragon.tinydragon" : "dutchangeldragons:mob.tinydragon.tinydragon") : "dutchangeldragons:mob.tinydragon.tinydragon");
  176. }
  177.  
  178. /**
  179. * Returns the sound this mob makes when it is hurt.
  180. */
  181. protected String getHurtSound()
  182. {
  183. return "dutchangeldragons:mob.tinydragon.tinydragon";
  184. }
  185.  
  186. /**
  187. * Returns the sound this mob makes on death.
  188. */
  189. protected String getDeathSound()
  190. {
  191. return "dutchangeldragons:mob.tinydragon.tinydragon";
  192. }
  193.  
  194. /**
  195. * Returns the volume for the sounds this mob makes.
  196. */
  197. protected float getSoundVolume()
  198. {
  199. return 0.4F;
  200. }
  201.  
  202. protected Item getDropItem()
  203. {
  204. return this.isBurning() ? DecoyDragonItems.dragonMeatCooked : DecoyDragonItems.dragonMeat;
  205. }
  206.  
  207. /**
  208. * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
  209. * par2 - Level of Looting used to kill this mob.
  210. */
  211. protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
  212. {
  213. int j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_);
  214.  
  215. for (int k = 0; k < j; ++k)
  216. {
  217. if (this.isBurning())
  218. {
  219. this.dropItem(DecoyDragonItems.dragonMeatCooked, 1);
  220. }
  221. else
  222. {
  223. this.dropItem(DecoyDragonItems.dragonMeat, 1);
  224. }
  225. }
  226.  
  227. }
  228. @SideOnly(Side.CLIENT)
  229. public int getBrightnessForRender(float p_70070_1_)
  230. {
  231. return 15728880;
  232. }
  233.  
  234. /**
  235. * Gets how bright this entity is.
  236. */
  237. public float getBrightness(float p_70013_1_)
  238. {
  239. return 1.0F;
  240. }
  241.  
  242. /**
  243. * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
  244. * use this to react to sunlight and start to burn.
  245. */
  246. public void onLivingUpdate()
  247. {
  248. super.onLivingUpdate();
  249.  
  250. if (!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround)
  251. {
  252. this.field_70928_h = true;
  253. this.timeWolfIsShaking = 0.0F;
  254. this.prevTimeWolfIsShaking = 0.0F;
  255. this.worldObj.setEntityState(this, (byte)8);
  256. }
  257. }
  258.  
  259. /**
  260. * Called to update the entity's position/logic.
  261. */
  262. public void onUpdate()
  263. {
  264. super.onUpdate();
  265. this.field_70924_f = this.field_70926_e;
  266.  
  267. if (this.func_70922_bv())
  268. {
  269. this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F;
  270. }
  271. else
  272. {
  273. this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F;
  274. }
  275.  
  276. if (this.func_70922_bv())
  277. {
  278. this.numTicksToChaseTarget = 10;
  279. }
  280.  
  281. if (this.isWet())
  282. {
  283. this.isShaking = true;
  284. this.field_70928_h = false;
  285. this.timeWolfIsShaking = 0.0F;
  286. this.prevTimeWolfIsShaking = 0.0F;
  287. }
  288. else if ((this.isShaking || this.field_70928_h) && this.field_70928_h)
  289. {
  290. if (this.timeWolfIsShaking == 0.0F)
  291. {
  292. this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
  293. }
  294.  
  295. this.prevTimeWolfIsShaking = this.timeWolfIsShaking;
  296. this.timeWolfIsShaking += 0.05F;
  297.  
  298. if (this.prevTimeWolfIsShaking >= 2.0F)
  299. {
  300. this.isShaking = false;
  301. this.field_70928_h = false;
  302. this.prevTimeWolfIsShaking = 0.0F;
  303. this.timeWolfIsShaking = 0.0F;
  304. }
  305.  
  306. if (this.timeWolfIsShaking > 0.4F)
  307. {
  308. float f = (float)this.boundingBox.minY;
  309. int i = (int)(MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float)Math.PI) * 7.0F);
  310.  
  311. for (int j = 0; j < i; ++j)
  312. {
  313. float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
  314. float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
  315. this.worldObj.spawnParticle("splash", this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ);
  316. }
  317. }
  318. }
  319. }
  320.  
  321. @SideOnly(Side.CLIENT)
  322. public boolean getWolfShaking()
  323. {
  324. return this.isShaking;
  325. }
  326.  
  327. /**
  328. * Used when calculating the amount of shading to apply while the wolf is shaking.
  329. */
  330. @SideOnly(Side.CLIENT)
  331. public float getShadingWhileShaking(float p_70915_1_)
  332. {
  333. return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F;
  334. }
  335.  
  336. @SideOnly(Side.CLIENT)
  337. public float getShakeAngle(float p_70923_1_, float p_70923_2_)
  338. {
  339. float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F;
  340.  
  341. if (f2 < 0.0F)
  342. {
  343. f2 = 0.0F;
  344. }
  345. else if (f2 > 1.0F)
  346. {
  347. f2 = 1.0F;
  348. }
  349.  
  350. return MathHelper.sin(f2 * (float)Math.PI) * MathHelper.sin(f2 * (float)Math.PI * 11.0F) * 0.15F * (float)Math.PI;
  351. }
  352.  
  353. public float getEyeHeight()
  354. {
  355. return this.height * 0.8F;
  356. }
  357.  
  358. @SideOnly(Side.CLIENT)
  359. public float getInterestedAngle(float p_70917_1_)
  360. {
  361. return (this.field_70924_f + (this.field_70926_e - this.field_70924_f) * p_70917_1_) * 0.15F * (float)Math.PI;
  362. }
  363.  
  364. /**
  365. * The speed it takes to move the entityliving's rotationPitch through the faceEntity method. This is only currently
  366. * use in wolves.
  367. */
  368. public int getVerticalFaceSpeed()
  369. {
  370. return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
  371. }
  372.  
  373. /**
  374. * Called when the entity is attacked.
  375. */
  376. public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_)
  377. {
  378. if (this.isEntityInvulnerable())
  379. {
  380. return false;
  381. }
  382. else
  383. {
  384. Entity entity = p_70097_1_.getEntity();
  385. this.aiSit.setSitting(false);
  386.  
  387. if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow))
  388. {
  389. p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F;
  390. }
  391.  
  392. return super.attackEntityFrom(p_70097_1_, p_70097_2_);
  393. }
  394. }
  395.  
  396. public boolean attackEntityAsMob(Entity p_70652_1_)
  397. {
  398. int i = this.isTamed() ? 4 : 2;
  399. return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i);
  400. }
  401.  
  402. public void setTamed(boolean p_70903_1_)
  403. {
  404. super.setTamed(p_70903_1_);
  405.  
  406. if (p_70903_1_)
  407. {
  408. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
  409. }
  410. else
  411. {
  412. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D);
  413. }
  414. }
  415.  
  416. /**
  417. * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
  418. */
  419. public boolean interact(EntityPlayer p_70085_1_)
  420. {
  421. ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();
  422.  
  423. if (this.isTamed())
  424. {
  425. if (itemstack != null)
  426. {
  427. if (itemstack.getItem() instanceof ItemFood)
  428. {
  429. ItemFood itemfood = (ItemFood)itemstack.getItem();
  430.  
  431. if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F)
  432. {
  433. if (!p_70085_1_.capabilities.isCreativeMode)
  434. {
  435. --itemstack.stackSize;
  436. }
  437.  
  438. this.heal((float)itemfood.func_150905_g(itemstack));
  439.  
  440. if (itemstack.stackSize <= 0)
  441. {
  442. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
  443. }
  444.  
  445. return true;
  446. }
  447. }
  448. else if (itemstack.getItem() == Items.dye)
  449. {
  450. int i = BlockColored.func_150032_b(itemstack.getItemDamage());
  451.  
  452. if (i != this.getCollarColor())
  453. {
  454. this.setCollarColor(i);
  455.  
  456. if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0)
  457. {
  458. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
  459. }
  460.  
  461. return true;
  462. }
  463. }
  464. }
  465.  
  466. if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack))
  467. {
  468. this.aiSit.setSitting(!this.isSitting());
  469. this.isJumping = false;
  470. this.setPathToEntity((PathEntity)null);
  471. this.setTarget((Entity)null);
  472. this.setAttackTarget((EntityLivingBase)null);
  473. }
  474. }
  475. else if (itemstack != null && itemstack.getItem() == Items.diamond && !this.isAngry())
  476. {
  477. if (!p_70085_1_.capabilities.isCreativeMode)
  478. {
  479. --itemstack.stackSize;
  480. }
  481.  
  482. if (itemstack.stackSize <= 0)
  483. {
  484. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
  485. }
  486.  
  487. if (!this.worldObj.isRemote)
  488. {
  489. if (this.rand.nextInt(3) == 0)
  490. {
  491. this.setTamed(true);
  492. this.setPathToEntity((PathEntity)null);
  493. this.setAttackTarget((EntityLivingBase)null);
  494. this.aiSit.setSitting(true);
  495. this.setHealth(999.0F);
  496. this.func_152115_b(p_70085_1_.getUniqueID().toString());
  497. this.playTameEffect(true);
  498. this.worldObj.setEntityState(this, (byte)7);
  499. }
  500. else
  501. {
  502. this.playTameEffect(false);
  503. this.worldObj.setEntityState(this, (byte)6);
  504. }
  505. }
  506.  
  507. return true;
  508. }
  509.  
  510. return super.interact(p_70085_1_);
  511. }
  512.  
  513.  
  514. @SideOnly(Side.CLIENT)
  515. public void handleHealthUpdate(byte p_70103_1_)
  516. {
  517. if (p_70103_1_ == 8)
  518. {
  519. this.field_70928_h = true;
  520. this.timeWolfIsShaking = 0.0F;
  521. this.prevTimeWolfIsShaking = 0.0F;
  522. }
  523. else
  524. {
  525. super.handleHealthUpdate(p_70103_1_);
  526. }
  527. }
  528.  
  529. @SideOnly(Side.CLIENT)
  530. public float getTailRotation()
  531. {
  532. return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float)Math.PI : ((float)Math.PI / 5F));
  533. }
  534.  
  535. /**
  536. * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
  537. * the animal type)
  538. */
  539.  
  540. public boolean isBreedingItem(ItemStack p_70877_1_)
  541. {
  542. return p_70877_1_ != null && p_70877_1_.getItem() == Items.beef;
  543. }
  544. /**
  545. * Will return how many at most can spawn in a chunk at once.
  546. */
  547. public int getMaxSpawnedInChunk()
  548. {
  549. return 2;
  550. }
  551.  
  552. /**
  553. * Determines whether this wolf is angry or not.
  554. */
  555. public boolean isAngry()
  556. {
  557. return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
  558. }
  559.  
  560. /**
  561. * Sets whether this wolf is angry or not.
  562. */
  563. public void setAngry(boolean p_70916_1_)
  564. {
  565. byte b0 = this.dataWatcher.getWatchableObjectByte(16);
  566.  
  567. if (p_70916_1_)
  568. {
  569. this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 2)));
  570. }
  571. else
  572. {
  573. this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -3)));
  574. }
  575. }
  576.  
  577. /**
  578. * Return this wolf's collar color.
  579. */
  580. public int getCollarColor()
  581. {
  582. return this.dataWatcher.getWatchableObjectByte(20) & 15;
  583. }
  584.  
  585. /**
  586. * Set this wolf's collar color.
  587. */
  588. public void setCollarColor(int p_82185_1_)
  589. {
  590. this.dataWatcher.updateObject(20, Byte.valueOf((byte)(p_82185_1_ & 15)));
  591. }
  592.  
  593. public EntityDiamondDragon createChild(EntityAgeable p_90011_1_)
  594. {
  595. EntityDiamondDragon entityalpsdragon = new EntityDiamondDragon(this.worldObj);
  596. String s = this.func_152113_b();
  597.  
  598. if (s != null && s.trim().length() > 0)
  599. {
  600. entityalpsdragon.func_152115_b(s);
  601. entityalpsdragon.setTamed(true);
  602. }
  603.  
  604. return entityalpsdragon;
  605. }
  606.  
  607. public void func_70918_i(boolean p_70918_1_)
  608. {
  609. if (p_70918_1_)
  610. {
  611. this.dataWatcher.updateObject(19, Byte.valueOf((byte)1));
  612. }
  613. else
  614. {
  615. this.dataWatcher.updateObject(19, Byte.valueOf((byte)0));
  616. }
  617. }
  618.  
  619. /**
  620. * Returns true if the mob is currently able to mate with the specified mob.
  621. */
  622. public boolean canMateWith(EntityAnimal p_70878_1_)
  623. {
  624. if (p_70878_1_ == this)
  625. {
  626. return false;
  627. }
  628. else if (!this.isTamed())
  629. {
  630. return false;
  631. }
  632. else if (!(p_70878_1_ instanceof EntityDiamondDragon))
  633. {
  634. return false;
  635. }
  636. else
  637. {
  638. EntityDiamondDragon entityalpsdragon = (EntityDiamondDragon)p_70878_1_;
  639. return !entityalpsdragon.isTamed() ? false : (entityalpsdragon.isSitting() ? false : this.isInLove() && entityalpsdragon.isInLove());
  640. }
  641. }
  642. //What Y it spawns at.
  643. public boolean getCanSpawnHere()
  644. {
  645. return this.posY < 16.0D && super.getCanSpawnHere();
  646. }
  647. protected boolean isValidLightLevel() {
  648. return true;
  649. }
  650. public boolean func_70922_bv()
  651. {
  652. return this.dataWatcher.getWatchableObjectByte(19) == 1;
  653. }
  654.  
  655. /**
  656. * Determines if an entity can be despawned, used on idle far away entities
  657. */
  658. protected boolean canDespawn()
  659. {
  660. return !this.isTamed() && this.ticksExisted > 2400;
  661. }
  662.  
  663. public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_)
  664. {
  665. if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast))
  666. {
  667. if (p_142018_1_ instanceof EntityDiamondDragon)
  668. {
  669. EntityDiamondDragon entityalpsdragon = (EntityDiamondDragon)p_142018_1_;
  670.  
  671. if (entityalpsdragon.isTamed() && entityalpsdragon.getOwner() == p_142018_2_)
  672. {
  673. return false;
  674. }
  675. }
  676.  
  677. return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer && !((EntityPlayer)p_142018_2_).canAttackPlayer((EntityPlayer)p_142018_1_) ? false : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse)p_142018_1_).isTame();
  678. }
  679. else
  680. {
  681. return false;
  682. }
  683.  
  684. }
  685. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement