Guest User

Untitled

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