Advertisement
Guest User

Untitled

a guest
Jun 5th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.51 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.util.ResourceLocation;
  55. import net.minecraft.world.World;
  56.  
  57. public class Familiar extends EntityTameable implements IMob, IBossDisplayData {
  58.  
  59. private float field_70926_e;
  60. private float field_70924_f;
  61. /** true is the wolf is wet else false */
  62. private boolean isShaking;
  63. private boolean field_70928_h;
  64. private float timeWolfIsShaking;
  65. private float prevTimeWolfIsShaking;
  66. public int lvl = 0;
  67. private static final String __OBFID = "CL_00001654";
  68.  
  69. private World world;
  70. private int x;
  71. private int y;
  72. private int z;
  73. private Random random;
  74. private int short1;
  75. private double d3;
  76. private double d4;
  77. private double d5;
  78. private RenderFamiliar RenderFamiliar;
  79.  
  80. private int k;
  81.  
  82. public Familiar(World p_i1696_1_) {
  83. super(p_i1696_1_);
  84. this.setSize(0.6F, 0.8F);
  85. this.getNavigator().setAvoidsWater(true);
  86. this.tasks.addTask(1, new EntityAISwimming(this));
  87. this.tasks.addTask(2, this.aiSit);
  88.  
  89. this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
  90. this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));
  91. this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
  92. this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
  93. this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  94.  
  95. this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  96. this.tasks.addTask(9, new EntityAILookIdle(this));
  97. this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
  98. this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));
  99. this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true));
  100. this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntitySheep.class, 200, false));
  101.  
  102. this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 3, true));
  103.  
  104. }
  105.  
  106. protected void applyEntityAttributes() {
  107. super.applyEntityAttributes();
  108. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);
  109.  
  110. if (this.isTamed()) {
  111. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(5.0D);
  112. } else {
  113. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
  114. }
  115. }
  116.  
  117. /**
  118. * Returns true if the newer Entity AI code should be run
  119. */
  120. public boolean isAIEnabled() {
  121. return true;
  122. }
  123.  
  124. /**
  125. * Sets the active target the Task system uses for tracking
  126. */
  127. public void setAttackTarget(EntityLivingBase p_70624_1_) {
  128. super.setAttackTarget(p_70624_1_);
  129.  
  130. if (p_70624_1_ == null) {
  131. this.setAngry(false);
  132. } else if (!this.isTamed()) {
  133. this.setAngry(true);
  134. } else if (this.lvl == 1) {
  135. this.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 210, 1));
  136.  
  137. }
  138. }
  139.  
  140. /**
  141. * main AI tick function, replaces updateEntityActionState
  142. */
  143. protected void updateAITick() {
  144. this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
  145. }
  146.  
  147. protected void entityInit() {
  148. super.entityInit();
  149. this.dataWatcher.addObject(18, new Float(this.getHealth()));
  150. this.dataWatcher.addObject(19, new Byte((byte) 0));
  151. this.dataWatcher.addObject(20, new Byte((byte) BlockColored.func_150032_b(1)));
  152. }
  153.  
  154. protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_) {
  155. this.playSound("mob.wolf.step", 0.15F, 1.0F);
  156. }
  157.  
  158. /**
  159. * (abstract) Protected helper method to write subclass entity data to NBT.
  160. */
  161. public void writeEntityToNBT(NBTTagCompound p_70014_1_) {
  162. super.writeEntityToNBT(p_70014_1_);
  163. p_70014_1_.setBoolean("Angry", this.isAngry());
  164. p_70014_1_.setByte("CollarColor", (byte) this.getCollarColor());
  165. }
  166.  
  167. /**
  168. * (abstract) Protected helper method to read subclass entity data from NBT.
  169. */
  170. public void readEntityFromNBT(NBTTagCompound p_70037_1_) {
  171. super.readEntityFromNBT(p_70037_1_);
  172. this.setAngry(p_70037_1_.getBoolean("Angry"));
  173.  
  174. if (p_70037_1_.hasKey("CollarColor", 99)) {
  175. this.setCollarColor(p_70037_1_.getByte("CollarColor"));
  176. }
  177. }
  178.  
  179. /**
  180. * Returns the sound this mob makes while it's alive.
  181. */
  182. public void updateEntityActionState() {
  183.  
  184. List list = worldObj.getEntitiesWithinAABB(EntityCreature.class,
  185. AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1, posY + 1, posZ + 1));
  186. for (int i = 0; i < list.size(); i++) {
  187. Entity entity = (Entity) list.get(i);
  188. if (!list.isEmpty()) {
  189. if (!(entity instanceof EntityPlayer)) {
  190. this.setTarget(entity);
  191. }
  192. }
  193. }
  194. super.updateEntityActionState();
  195. }
  196.  
  197. /**
  198. * Returns the volume for the sounds this mob makes.
  199. */
  200. protected float getSoundVolume() {
  201. return 0.4F;
  202. }
  203.  
  204. /**
  205. * Called frequently so the entity can update its state every tick as
  206. * required. For example, zombies and skeletons use this to react to
  207. * sunlight and start to burn.
  208. */
  209. public void onLivingUpdate() {
  210. super.onLivingUpdate();
  211.  
  212. if (!this.worldObj.isRemote && this.isShaking && !this.field_70928_h && !this.hasPath() && this.onGround) {
  213. this.field_70928_h = true;
  214. this.timeWolfIsShaking = 0.0F;
  215. this.prevTimeWolfIsShaking = 0.0F;
  216. this.worldObj.setEntityState(this, (byte) 8);
  217. }
  218. for (k = 0; k < 2; ++k) {
  219. this.worldObj.spawnParticle("enchantmenttable",
  220. this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width,
  221. this.posY + this.rand.nextDouble() * (double) this.height - 0.25D,
  222. this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width,
  223. (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(),
  224. (this.rand.nextDouble() - 0.5D) * 2.0D);
  225. }
  226. }
  227.  
  228. public void onUpdate() {
  229. super.onUpdate();
  230. this.field_70924_f = this.field_70926_e;
  231.  
  232. if (this.func_70922_bv()) {
  233. this.field_70926_e += (1.0F - this.field_70926_e) * 0.4F;
  234. } else {
  235. this.field_70926_e += (0.0F - this.field_70926_e) * 0.4F;
  236. }
  237.  
  238. if (this.func_70922_bv()) {
  239. this.numTicksToChaseTarget = 10;
  240. }
  241.  
  242. if (this.isWet()) {
  243. this.isShaking = true;
  244. this.field_70928_h = false;
  245. this.timeWolfIsShaking = 0.0F;
  246. this.prevTimeWolfIsShaking = 0.0F;
  247. } else if ((this.isShaking || this.field_70928_h) && this.field_70928_h) {
  248. if (this.timeWolfIsShaking == 0.0F) {
  249. this.playSound("mob.wolf.shake", this.getSoundVolume(),
  250. (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
  251. }
  252.  
  253. this.prevTimeWolfIsShaking = this.timeWolfIsShaking;
  254. this.timeWolfIsShaking += 0.05F;
  255.  
  256. if (this.prevTimeWolfIsShaking >= 2.0F) {
  257. this.isShaking = false;
  258. this.field_70928_h = false;
  259. this.prevTimeWolfIsShaking = 0.0F;
  260. this.timeWolfIsShaking = 0.0F;
  261. }
  262.  
  263. if (this.timeWolfIsShaking > 0.4F) {
  264. float f = (float) this.boundingBox.minY;
  265. int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F);
  266.  
  267. for (int j = 0; j < i; ++j) {
  268. float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
  269. float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
  270. this.worldObj.spawnParticle("splash", this.posX + (double) f1, (double) (f + 0.8F),
  271. this.posZ + (double) f2, this.motionX, this.motionY, this.motionZ);
  272. }
  273. }
  274. }
  275. }
  276.  
  277. @SideOnly(Side.CLIENT)
  278. public boolean getWolfShaking() {
  279. return this.isShaking;
  280. }
  281.  
  282. @SideOnly(Side.CLIENT)
  283. public float getShadingWhileShaking(float p_70915_1_) {
  284. return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_)
  285. / 2.0F * 0.25F;
  286. }
  287.  
  288. @SideOnly(Side.CLIENT)
  289. public float getShakeAngle(float p_70923_1_, float p_70923_2_) {
  290. float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_
  291. + p_70923_2_) / 1.8F;
  292.  
  293. if (f2 < 0.0F) {
  294. f2 = 0.0F;
  295. } else if (f2 > 1.0F) {
  296. f2 = 1.0F;
  297. }
  298.  
  299. return MathHelper.sin(f2 * (float) Math.PI) * MathHelper.sin(f2 * (float) Math.PI * 11.0F) * 0.15F
  300. * (float) Math.PI;
  301. }
  302.  
  303. public float getEyeHeight() {
  304. return this.height * 0.8F;
  305. }
  306.  
  307. @SideOnly(Side.CLIENT)
  308. public float getInterestedAngle(float p_70917_1_) {
  309. return (this.field_70924_f + (this.field_70926_e - this.field_70924_f) * p_70917_1_) * 0.15F * (float) Math.PI;
  310. }
  311.  
  312. /**
  313. * The speed it takes to move the entityliving's rotationPitch through the
  314. * faceEntity method. This is only currently use in wolves.
  315. */
  316. public int getVerticalFaceSpeed() {
  317. return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
  318. }
  319.  
  320. /**
  321. * Called when the entity is attacked.
  322. */
  323. public boolean attackEntityFrom(DamageSource p_70097_1_, float p_70097_2_) {
  324. if (this.isEntityInvulnerable()) {
  325. return false;
  326. } else {
  327. Entity entity = p_70097_1_.getEntity();
  328. this.aiSit.setSitting(false);
  329.  
  330. if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) {
  331. p_70097_2_ = (p_70097_2_ + 1.0F) / 2.0F;
  332. }
  333.  
  334. return super.attackEntityFrom(p_70097_1_, p_70097_2_);
  335. }
  336. }
  337.  
  338. public boolean attackEntityAsMob(Entity p_70652_1_) {
  339. int i = this.isTamed() ? 4 : 2;
  340. return p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) i);
  341. }
  342.  
  343. public void setTamed() {
  344.  
  345. if (this.lvl == 1) {
  346. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
  347. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.5D);
  348.  
  349. }
  350. if (this.lvl == 2) {
  351. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D);
  352. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.7D);
  353. }
  354. if (this.lvl == 3) {
  355. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(200.0D);
  356. } else if (this.lvl == 0) {
  357. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
  358. }
  359.  
  360. }
  361.  
  362. /**
  363. * Called when a player interacts with a mob. e.g. gets milk from a cow,
  364. * gets into the saddle on a pig.
  365. */
  366. public boolean interact(EntityPlayer p_70085_1_) {
  367. ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();
  368.  
  369. if (this.lvl > 0) {
  370. if (itemstack != null) {
  371. if (itemstack.getItem() instanceof Baie) {
  372. Baie itemfood = (Baie) itemstack.getItem();
  373.  
  374. if (itemfood.isFamiliarFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) {
  375. if (!p_70085_1_.capabilities.isCreativeMode) {
  376. --itemstack.stackSize;
  377. }
  378.  
  379. this.heal((float) itemfood.func_150905_g(itemstack));
  380.  
  381. if (itemstack.stackSize <= 0) {
  382. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem,
  383. (ItemStack) null);
  384. }
  385.  
  386. return true;
  387. }
  388. } else if (itemstack.getItem() == Items.dye) {
  389. int i = BlockColored.func_150032_b(itemstack.getItemDamage());
  390.  
  391. if (i != this.getCollarColor()) {
  392. this.setCollarColor(i);
  393.  
  394. if (!p_70085_1_.capabilities.isCreativeMode && --itemstack.stackSize <= 0) {
  395. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem,
  396. (ItemStack) null);
  397. }
  398.  
  399. return true;
  400. }
  401. }
  402. }
  403.  
  404. if (this.func_152114_e(p_70085_1_) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) {
  405. this.aiSit.setSitting(!this.isSitting());
  406. this.isJumping = false;
  407. this.setPathToEntity((PathEntity) null);
  408. this.setTarget((Entity) null);
  409. this.setAttackTarget((EntityLivingBase) null);
  410. }
  411. } else if (itemstack != null && itemstack.getItem() == enderdeath.GoldenCroquette) {
  412.  
  413. System.out.println("je suis dans le else if ");
  414. if (!p_70085_1_.capabilities.isCreativeMode) {
  415. --itemstack.stackSize;
  416. System.out.println("je suis dans le if !p_70085_1_.capabilities.isCreativeMode");
  417. }
  418.  
  419. if (itemstack.stackSize <= 0) {
  420. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null);
  421. System.out.println(
  422. "je suis dans le if p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null); ");
  423. }
  424.  
  425. if (!this.worldObj.isRemote) {
  426. if (this.rand.nextInt(3) == 0) {
  427.  
  428. System.out.println("TEST" + this.isTamed());
  429.  
  430. this.lvl = 2;
  431. this.setTamed();
  432. this.isTamed();
  433. System.out.println(lvl);
  434.  
  435. this.setPathToEntity((PathEntity) null);
  436. this.setAttackTarget((EntityLivingBase) null);
  437. this.aiSit.setSitting(true);
  438. this.func_152115_b(p_70085_1_.getUniqueID().toString());
  439. this.playTameEffect(true);
  440. this.worldObj.setEntityState(this, (byte) 7);
  441.  
  442. } else {
  443. this.playTameEffect(false);
  444. this.worldObj.setEntityState(this, (byte) 6);
  445. }
  446. } else if (itemstack != null && itemstack.getItem() == enderdeath.RubisCroquette && this.isTamed()
  447. && this.lvl == 2) {
  448. System.out.println("GAGNE");
  449.  
  450. if (!p_70085_1_.capabilities.isCreativeMode) {
  451. --itemstack.stackSize;
  452. }
  453.  
  454. if (itemstack.stackSize <= 0) {
  455. p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack) null);
  456. }
  457.  
  458. if (!this.worldObj.isRemote) {
  459. if (this.rand.nextInt(3) == 0) {
  460.  
  461. this.setPathToEntity((PathEntity) null);
  462. this.setAttackTarget((EntityLivingBase) null);
  463. this.aiSit.setSitting(true);
  464. System.out.println("GAGNE");
  465. this.lvl = 3;
  466.  
  467. this.func_152115_b(p_70085_1_.getUniqueID().toString());
  468. this.playTameEffect(true);
  469. this.worldObj.setEntityState(this, (byte) 7);
  470. this.setTamed();
  471. } else {
  472. this.playTameEffect(false);
  473. this.worldObj.setEntityState(this, (byte) 6);
  474. }
  475. if (itemstack != null && itemstack.getItem() == enderdeath.SkinFire && this.isTamed()) {
  476. this.Chanchelog();
  477. this.onParticuleFire();
  478. }
  479. }
  480. }
  481. return true;
  482. }
  483.  
  484. return super.interact(p_70085_1_);
  485. }
  486.  
  487. private ResourceLocation Chanchelog() {
  488. return RenderFamiliar.textureSkin;
  489.  
  490. }
  491.  
  492. public void onParticuleFire() {
  493. for (k = 0; k < 2; ++k) {
  494. this.worldObj.spawnParticle("fire", this.posX + (this.rand.nextDouble() - 0.5D) * (double) this.width,
  495. this.posY + this.rand.nextDouble() * (double) this.height - 0.25D,
  496. this.posZ + (this.rand.nextDouble() - 0.5D) * (double) this.width,
  497. (this.rand.nextDouble() - 0.5D) * 2.0D, -this.rand.nextDouble(),
  498. (this.rand.nextDouble() - 0.5D) * 2.0D);
  499. }
  500. }
  501.  
  502. @SideOnly(Side.CLIENT)
  503. public float getTailRotation() {
  504. return this.isAngry() ? 1.5393804F
  505. : (this.isTamed()
  506. ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float) Math.PI
  507. : ((float) Math.PI / 5F));
  508. }
  509.  
  510. public boolean isBreedingItem(ItemStack p_70877_1_) {
  511. return p_70877_1_ == null ? false
  512. : (!(p_70877_1_.getItem() instanceof Baie) ? false
  513. : ((Baie) p_70877_1_.getItem()).isFamiliarFavoriteMeat());
  514. }
  515.  
  516. public boolean isAngry() {
  517. return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
  518. }
  519.  
  520. public void setAngry(boolean p_70916_1_) {
  521. byte b0 = this.dataWatcher.getWatchableObjectByte(16);
  522.  
  523. if (p_70916_1_) {
  524. this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
  525. } else {
  526. this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
  527. }
  528. }
  529.  
  530. public int getCollarColor() {
  531. return this.dataWatcher.getWatchableObjectByte(20) & 15;
  532. }
  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.lvl >= 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 familiar = (Familiar) p_70878_1_;
  571. return !familiar.isTamed() ? false
  572. : (familiar.isSitting() ? false : this.isInLove() && familiar.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
Advertisement