Advertisement
Guest User

Untitled

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