Guest User

Untitled

a guest
Dec 22nd, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.19 KB | None | 0 0
  1. package jip.jipmod.init.modEntityClasses;
  2.  
  3. import java.util.Calendar;
  4. import java.util.List;
  5. import java.util.UUID;
  6.  
  7. import jip.jipmod.init.TutorialItems;
  8. import net.minecraft.block.Block;
  9. import net.minecraft.command.IEntitySelector;
  10. import net.minecraft.entity.Entity;
  11. import net.minecraft.entity.EntityLiving;
  12. import net.minecraft.entity.EntityLivingBase;
  13. import net.minecraft.entity.EnumCreatureAttribute;
  14. import net.minecraft.entity.IEntityLivingData;
  15. import net.minecraft.entity.SharedMonsterAttributes;
  16. import net.minecraft.entity.ai.EntityAIAttackOnCollide;
  17. import net.minecraft.entity.ai.EntityAIBreakDoor;
  18. import net.minecraft.entity.ai.EntityAIHurtByTarget;
  19. import net.minecraft.entity.ai.EntityAILookIdle;
  20. import net.minecraft.entity.ai.EntityAIMoveThroughVillage;
  21. import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction;
  22. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  23. import net.minecraft.entity.ai.EntityAISwimming;
  24. import net.minecraft.entity.ai.EntityAIWander;
  25. import net.minecraft.entity.ai.EntityAIWatchClosest;
  26. import net.minecraft.entity.ai.attributes.AttributeModifier;
  27. import net.minecraft.entity.ai.attributes.IAttribute;
  28. import net.minecraft.entity.ai.attributes.IAttributeInstance;
  29. import net.minecraft.entity.ai.attributes.RangedAttribute;
  30. import net.minecraft.entity.monster.EntityCreeper;
  31. import net.minecraft.entity.monster.EntityIronGolem;
  32. import net.minecraft.entity.monster.EntityPigZombie;
  33. import net.minecraft.entity.monster.EntityZombie;
  34. import net.minecraft.entity.passive.EntityChicken;
  35. import net.minecraft.entity.passive.EntityVillager;
  36. import net.minecraft.entity.player.EntityPlayer;
  37. import net.minecraft.init.Blocks;
  38. import net.minecraft.init.Items;
  39. import net.minecraft.item.Item;
  40. import net.minecraft.item.ItemStack;
  41. import net.minecraft.nbt.NBTTagCompound;
  42. import net.minecraft.pathfinding.PathNavigateGround;
  43. import net.minecraft.potion.Potion;
  44. import net.minecraft.potion.PotionEffect;
  45. import net.minecraft.util.BlockPos;
  46. import net.minecraft.util.DamageSource;
  47. import net.minecraft.util.MathHelper;
  48. import net.minecraft.world.DifficultyInstance;
  49. import net.minecraft.world.EnumDifficulty;
  50. import net.minecraft.world.World;
  51. import net.minecraftforge.fml.relauncher.Side;
  52. import net.minecraftforge.fml.relauncher.SideOnly;
  53.  
  54.  
  55. public class EntityHorror extends EntityZombie{
  56.  
  57. /** The attribute which determines the chance that this mob will spawn reinforcements */
  58. protected static final IAttribute reinforcementChance = (new RangedAttribute((IAttribute)null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).setDescription("Spawn Reinforcements Chance");
  59. private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
  60. private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1);
  61. private final EntityAIBreakDoor breakDoor = new EntityAIBreakDoor(this);
  62. /** Ticker used to determine the time remaining for this zombie to convert into a villager when cured. */
  63. private int conversionTime;
  64. private boolean field_146076_bu = false;
  65. /** The width of the entity */
  66. // private float zombieWidth = -1.0F;
  67. /** The height of the the entity. */
  68. //private float zombieHeight;
  69.  
  70. public EntityHorror(World worldIn)
  71. {
  72. super(worldIn);
  73. ((PathNavigateGround)this.getNavigator()).func_179688_b(true);
  74. this.tasks.addTask(0, new EntityAISwimming(this));
  75. this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
  76. this.tasks.addTask(2, this.field_175455_a);
  77. this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
  78. this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
  79. this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
  80. this.tasks.addTask(8, new EntityAILookIdle(this));
  81. this.applyEntityAI();
  82. this.setSize(0.6F, 1.95F);
  83. }
  84.  
  85. protected void applyEntityAI()
  86. {
  87. this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
  88. this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityIronGolem.class, 1.0D, true));
  89. this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
  90. this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] {EntityPigZombie.class}));
  91. this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
  92. this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
  93. this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));
  94. }
  95.  
  96. protected void applyEntityAttributes()
  97. {
  98. super.applyEntityAttributes();
  99. this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(35.0D);
  100. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.26000000417232513D);
  101. this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10.0D);
  102. }
  103.  
  104.  
  105.  
  106.  
  107. public void func_146070_a(boolean p_146070_1_)
  108. {
  109. if (this.field_146076_bu != p_146070_1_)
  110. {
  111. this.field_146076_bu = p_146070_1_;
  112.  
  113. if (p_146070_1_)
  114. {
  115. this.tasks.addTask(1, this.breakDoor);
  116. }
  117. else
  118. {
  119. this.tasks.removeTask(this.breakDoor);
  120. }
  121. }
  122. }
  123.  
  124. /**
  125. * Get the experience points the entity currently has.
  126. */
  127. protected int getExperiencePoints(EntityPlayer player)
  128. {
  129. if (this.isChild())
  130. {
  131. this.experienceValue = (int)((float)this.experienceValue * 2.5F);
  132. }
  133.  
  134. return super.getExperiencePoints(player);
  135. }
  136.  
  137.  
  138. /**
  139. * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
  140. * use this to react to sunlight and start to burn.
  141. */
  142. public void onLivingUpdate()
  143. {
  144. if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild())
  145. {
  146. float f = this.getBrightness(1.0F);
  147. BlockPos blockpos = new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);
  148.  
  149. if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
  150. {
  151. boolean flag = true;
  152. ItemStack itemstack = this.getEquipmentInSlot(4);
  153.  
  154. if (itemstack != null)
  155. {
  156. if (itemstack.isItemStackDamageable())
  157. {
  158. itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
  159.  
  160. if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
  161. {
  162. this.renderBrokenItemStack(itemstack);
  163. this.setCurrentItemOrArmor(4, (ItemStack)null);
  164. }
  165. }
  166.  
  167. flag = false;
  168. }
  169.  
  170. if (flag)
  171. {
  172. this.setFire(8);
  173. }
  174. }
  175. }
  176.  
  177. if (this.isRiding() && this.getAttackTarget() != null && this.ridingEntity instanceof EntityChicken)
  178. {
  179. ((EntityLiving)this.ridingEntity).getNavigator().setPath(this.getNavigator().getPath(), 1.5D);
  180. }
  181.  
  182. super.onLivingUpdate();
  183. }
  184.  
  185. /**
  186. * Called when the entity is attacked.
  187. */
  188. public boolean attackEntityFrom(DamageSource source, float amount)
  189. {
  190. if (super.attackEntityFrom(source, amount))
  191. {
  192. EntityLivingBase entitylivingbase = this.getAttackTarget();
  193.  
  194. if (entitylivingbase == null && source.getEntity() instanceof EntityLivingBase)
  195. {
  196. entitylivingbase = (EntityLivingBase)source.getEntity();
  197. }
  198.  
  199. int i = MathHelper.floor_double(this.posX);
  200. int j = MathHelper.floor_double(this.posY);
  201. int k = MathHelper.floor_double(this.posZ);
  202.  
  203. net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent summonAid = net.minecraftforge.event.ForgeEventFactory.fireZombieSummonAid(this, worldObj, i, j, k, entitylivingbase, this.getEntityAttribute(reinforcementChance).getAttributeValue());
  204. if (summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY) return true;
  205.  
  206. if (summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW ||
  207. entitylivingbase != null && this.worldObj.getDifficulty() == EnumDifficulty.HARD && (double)this.rand.nextFloat() < this.getEntityAttribute(reinforcementChance).getAttributeValue())
  208. {
  209. EntityZombie entityzombie;
  210. if (summonAid.customSummonedAid != null && summonAid.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW)
  211. {
  212. entityzombie = summonAid.customSummonedAid;
  213. }
  214. else
  215. {
  216. entityzombie = new EntityZombie(this.worldObj);
  217. }
  218.  
  219. for (int l = 0; l < 50; ++l)
  220. {
  221. int i1 = i + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
  222. int j1 = j + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
  223. int k1 = k + MathHelper.getRandomIntegerInRange(this.rand, 7, 40) * MathHelper.getRandomIntegerInRange(this.rand, -1, 1);
  224.  
  225. if (World.doesBlockHaveSolidTopSurface(this.worldObj, new BlockPos(i1, j1 - 1, k1)) && this.worldObj.getLightFromNeighbors(new BlockPos(i1, j1, k1)) < 10)
  226. {
  227. entityzombie.setPosition((double)i1, (double)j1, (double)k1);
  228.  
  229. if (!this.worldObj.func_175636_b((double)i1, (double)j1, (double)k1, 7.0D) && this.worldObj.checkNoEntityCollision(entityzombie.getEntityBoundingBox(), entityzombie) && this.worldObj.getCollidingBoundingBoxes(entityzombie, entityzombie.getEntityBoundingBox()).isEmpty() && !this.worldObj.isAnyLiquid(entityzombie.getEntityBoundingBox()))
  230. {
  231. this.worldObj.spawnEntityInWorld(entityzombie);
  232. if (entitylivingbase != null) entityzombie.setAttackTarget(entitylivingbase);
  233. entityzombie.func_180482_a(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
  234. this.getEntityAttribute(reinforcementChance).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
  235. entityzombie.getEntityAttribute(reinforcementChance).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, 0));
  236. break;
  237. }
  238. }
  239. }
  240. }
  241.  
  242. return true;
  243. }
  244. else
  245. {
  246. return false;
  247. }
  248. }
  249.  
  250. /**
  251. * Called to update the entity's position/logic.
  252. */
  253. public void onUpdate()
  254. {
  255. if (!this.worldObj.isRemote && this.isConverting())
  256. {
  257. int i = this.getConversionTimeBoost();
  258. this.conversionTime -= i;
  259.  
  260. if (this.conversionTime <= 0)
  261. {
  262. this.convertToVillager();
  263. }
  264. }
  265.  
  266. super.onUpdate();
  267. }
  268.  
  269. public boolean attackEntityAsMob(Entity p_70652_1_)
  270. {
  271. boolean flag = super.attackEntityAsMob(p_70652_1_);
  272.  
  273. if (flag)
  274. {
  275. int i = this.worldObj.getDifficulty().getDifficultyId();
  276.  
  277. if (this.getHeldItem() == null && this.isBurning() && this.rand.nextFloat() < (float)i * 0.3F)
  278. {
  279. p_70652_1_.setFire(2 * i);
  280. }
  281. }
  282.  
  283. return flag;
  284. }
  285.  
  286. /**
  287. * Returns the sound this mob makes while it's alive.
  288. */
  289. protected String getLivingSound()
  290. {
  291. return "mob.wither.say";
  292. }
  293.  
  294. /**
  295. * Returns the sound this mob makes when it is hurt.
  296. */
  297. protected String getHurtSound()
  298. {
  299. return "mob.wither.hurt";
  300. }
  301.  
  302. /**
  303. * Returns the sound this mob makes on death.
  304. */
  305. protected String getDeathSound()
  306. {
  307. return "mob.wither.death";
  308. }
  309.  
  310. protected void playStepSound(BlockPos p_180429_1_, Block p_180429_2_)
  311. {
  312. this.playSound("mob.wither.step", 0.15F, 1.0F);
  313. }
  314.  
  315. protected Item getDropItem()
  316. {
  317. return TutorialItems.grimdark_essence;
  318. }
  319.  
  320. /**
  321. * Get this Entity's EnumCreatureAttribute
  322. */
  323. public EnumCreatureAttribute getCreatureAttribute()
  324. {
  325. return EnumCreatureAttribute.UNDEAD;
  326. }
  327.  
  328. /**
  329. * (abstract) Protected helper method to write subclass entity data to NBT.
  330. */
  331. public void writeEntityToNBT(NBTTagCompound tagCompound)
  332. {
  333. super.writeEntityToNBT(tagCompound);
  334.  
  335. if (this.isChild())
  336. {
  337. tagCompound.setBoolean("IsBaby", true);
  338. }
  339.  
  340. if (this.isVillager())
  341. {
  342. tagCompound.setBoolean("IsVillager", true);
  343. }
  344.  
  345. tagCompound.setInteger("ConversionTime", this.isConverting() ? this.conversionTime : -1);
  346. tagCompound.setBoolean("CanBreakDoors", this.func_146072_bX());
  347. }
  348.  
  349. /**
  350. * (abstract) Protected helper method to read subclass entity data from NBT.
  351. */
  352. public void readEntityFromNBT(NBTTagCompound tagCompund)
  353. {
  354. super.readEntityFromNBT(tagCompund);
  355.  
  356. if (tagCompund.getBoolean("IsBaby"))
  357. {
  358. this.setChild(true);
  359. }
  360.  
  361. if (tagCompund.getBoolean("IsVillager"))
  362. {
  363. this.setVillager(true);
  364. }
  365.  
  366. if (tagCompund.hasKey("ConversionTime", 99) && tagCompund.getInteger("ConversionTime") > -1)
  367. {
  368. this.startConversion(tagCompund.getInteger("ConversionTime"));
  369. }
  370.  
  371. this.func_146070_a(tagCompund.getBoolean("CanBreakDoors"));
  372. }
  373.  
  374. /**
  375. * This method gets called when the entity kills another one.
  376. */
  377. public void onKillEntity(EntityLivingBase entityLivingIn)
  378. {
  379. super.onKillEntity(entityLivingIn);
  380.  
  381. if ((this.worldObj.getDifficulty() == EnumDifficulty.NORMAL || this.worldObj.getDifficulty() == EnumDifficulty.HARD) && entityLivingIn instanceof EntityVillager)
  382. {
  383. if (this.worldObj.getDifficulty() != EnumDifficulty.HARD && this.rand.nextBoolean())
  384. {
  385. return;
  386. }
  387.  
  388. EntityZombie entityzombie = new EntityZombie(this.worldObj);
  389. entityzombie.copyLocationAndAnglesFrom(entityLivingIn);
  390. this.worldObj.removeEntity(entityLivingIn);
  391. entityzombie.func_180482_a(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
  392. entityzombie.setVillager(true);
  393.  
  394. if (entityLivingIn.isChild())
  395. {
  396. entityzombie.setChild(true);
  397. }
  398.  
  399. this.worldObj.spawnEntityInWorld(entityzombie);
  400. this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1016, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
  401. }
  402. }
  403.  
  404. public float getEyeHeight()
  405. {
  406. float f = 1.74F;
  407.  
  408. if (this.isChild())
  409. {
  410. f = (float)((double)f - 0.81D);
  411. }
  412.  
  413. return f;
  414. }
  415.  
  416. protected boolean func_175448_a(ItemStack p_175448_1_)
  417. {
  418. return p_175448_1_.getItem() == Items.egg && this.isChild() && this.isRiding() ? false : super.func_175448_a(p_175448_1_);
  419. }
  420.  
  421. public IEntityLivingData func_180482_a(DifficultyInstance p_180482_1_, IEntityLivingData p_180482_2_)
  422. {
  423. Object p_180482_2_1 = super.func_180482_a(p_180482_1_, p_180482_2_);
  424. float f = p_180482_1_.getClampedAdditionalDifficulty();
  425. this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
  426.  
  427. if (p_180482_2_1 == null)
  428. {
  429. p_180482_2_1 = new EntityHorror.GroupData(this.worldObj.rand.nextFloat() < net.minecraftforge.common.ForgeModContainer.zombieBabyChance, this.worldObj.rand.nextFloat() < 0.05F, null);
  430. }
  431.  
  432. if (p_180482_2_1 instanceof EntityHorror.GroupData)
  433. {
  434. EntityHorror.GroupData groupdata = (EntityHorror.GroupData)p_180482_2_1;
  435.  
  436. if (groupdata.field_142046_b)
  437. {
  438. this.setVillager(true);
  439. }
  440.  
  441. if (groupdata.field_142048_a)
  442. {
  443. this.setChild(true);
  444.  
  445. if ((double)this.worldObj.rand.nextFloat() < 0.05D)
  446. {
  447. List list = this.worldObj.getEntitiesWithinAABB(EntityChicken.class, this.getEntityBoundingBox().expand(5.0D, 3.0D, 5.0D), IEntitySelector.IS_STANDALONE);
  448.  
  449. if (!list.isEmpty())
  450. {
  451. EntityChicken entitychicken = (EntityChicken)list.get(0);
  452. entitychicken.setChickenJockey(true);
  453. this.mountEntity(entitychicken);
  454. }
  455. }
  456. else if ((double)this.worldObj.rand.nextFloat() < 0.05D)
  457. {
  458. EntityChicken entitychicken1 = new EntityChicken(this.worldObj);
  459. entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
  460. entitychicken1.func_180482_a(p_180482_1_, (IEntityLivingData)null);
  461. entitychicken1.setChickenJockey(true);
  462. this.worldObj.spawnEntityInWorld(entitychicken1);
  463. this.mountEntity(entitychicken1);
  464. }
  465. }
  466. }
  467.  
  468. this.func_146070_a(this.rand.nextFloat() < f * 0.1F);
  469. this.func_180481_a(p_180482_1_);
  470. this.func_180483_b(p_180482_1_);
  471.  
  472. if (this.getEquipmentInSlot(4) == null)
  473. {
  474. Calendar calendar = this.worldObj.getCurrentDate();
  475.  
  476. if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F)
  477. {
  478. this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin));
  479. this.equipmentDropChances[4] = 0.0F;
  480. }
  481. }
  482.  
  483. this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.nextDouble() * 0.05000000074505806D, 0));
  484. double d0 = this.rand.nextDouble() * 1.5D * (double)f;
  485.  
  486. if (d0 > 1.0D)
  487. {
  488. this.getEntityAttribute(SharedMonsterAttributes.followRange).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, 2));
  489. }
  490.  
  491. if (this.rand.nextFloat() < f * 0.05F)
  492. {
  493. this.getEntityAttribute(reinforcementChance).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 0.25D + 0.5D, 0));
  494. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.nextDouble() * 3.0D + 1.0D, 2));
  495. this.func_146070_a(true);
  496. }
  497.  
  498. return (IEntityLivingData)p_180482_2_1;
  499. }
  500.  
  501.  
  502. /**
  503. * Starts converting this zombie into a villager. The zombie converts into a villager after the specified time in
  504. * ticks.
  505. */
  506. protected void startConversion(int p_82228_1_)
  507. {
  508. this.conversionTime = p_82228_1_;
  509. this.getDataWatcher().updateObject(14, Byte.valueOf((byte)1));
  510. this.removePotionEffect(Potion.weakness.id);
  511. this.addPotionEffect(new PotionEffect(Potion.damageBoost.id, p_82228_1_, Math.min(this.worldObj.getDifficulty().getDifficultyId() - 1, 0)));
  512. this.worldObj.setEntityState(this, (byte)16);
  513. }
  514.  
  515. @SideOnly(Side.CLIENT)
  516. public void handleHealthUpdate(byte p_70103_1_)
  517. {
  518. if (p_70103_1_ == 16)
  519. {
  520. if (!this.isSilent())
  521. {
  522. this.worldObj.playSound(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D, "mob.zombie.remedy", 1.0F + this.rand.nextFloat(), this.rand.nextFloat() * 0.7F + 0.3F, false);
  523. }
  524. }
  525. else
  526. {
  527. super.handleHealthUpdate(p_70103_1_);
  528. }
  529. }
  530.  
  531. /**
  532. * Determines if an entity can be despawned, used on idle far away entities
  533. */
  534. protected boolean canDespawn()
  535. {
  536. return !this.isConverting();
  537. }
  538.  
  539. /**
  540. * Returns whether this zombie is in the process of converting to a villager
  541. */
  542. public boolean isConverting()
  543. {
  544. return this.getDataWatcher().getWatchableObjectByte(14) == 1;
  545. }
  546.  
  547. /**
  548. * Convert this zombie into a villager.
  549. */
  550. protected void convertToVillager()
  551. {
  552. EntityVillager entityvillager = new EntityVillager(this.worldObj);
  553. entityvillager.copyLocationAndAnglesFrom(this);
  554. entityvillager.func_180482_a(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
  555. entityvillager.setLookingForHome();
  556.  
  557. if (this.isChild())
  558. {
  559. entityvillager.setGrowingAge(-24000);
  560. }
  561.  
  562. this.worldObj.removeEntity(this);
  563. this.worldObj.spawnEntityInWorld(entityvillager);
  564. entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
  565. this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
  566. }
  567.  
  568. /**
  569. * Return the amount of time decremented from conversionTime every tick.
  570. */
  571. protected int getConversionTimeBoost()
  572. {
  573. int i = 1;
  574.  
  575. if (this.rand.nextFloat() < 0.01F)
  576. {
  577. int j = 0;
  578.  
  579. for (int k = (int)this.posX - 4; k < (int)this.posX + 4 && j < 14; ++k)
  580. {
  581. for (int l = (int)this.posY - 4; l < (int)this.posY + 4 && j < 14; ++l)
  582. {
  583. for (int i1 = (int)this.posZ - 4; i1 < (int)this.posZ + 4 && j < 14; ++i1)
  584. {
  585. Block block = this.worldObj.getBlockState(new BlockPos(k, l, i1)).getBlock();
  586.  
  587. if (block == Blocks.iron_bars || block == Blocks.bed)
  588. {
  589. if (this.rand.nextFloat() < 0.3F)
  590. {
  591. ++i;
  592. }
  593.  
  594. ++j;
  595. }
  596. }
  597. }
  598. }
  599. }
  600.  
  601. return i;
  602. }
  603.  
  604. /**
  605. * sets the size of the entity to be half of its current size if true.
  606. *
  607. * @param isChild If the mob is a child it's height and width will be halved. Otherwise the size will remain the
  608. * same.
  609. */
  610. public void setChildSize(boolean isChild)
  611. {
  612. this.multiplySize(isChild ? 0.5F : 1.0F);
  613. }
  614.  
  615.  
  616.  
  617. /**
  618. * Returns the Y Offset of this entity.
  619. */
  620. public double getYOffset()
  621. {
  622. return super.getYOffset() - 0.5D;
  623. }
  624.  
  625.  
  626. class GroupData implements IEntityLivingData
  627. {
  628. public boolean field_142048_a;
  629. public boolean field_142046_b;
  630. private static final String __OBFID = "CL_00001704";
  631.  
  632. private GroupData(boolean p_i2348_2_, boolean p_i2348_3_)
  633. {
  634. this.field_142048_a = false;
  635. this.field_142046_b = false;
  636. this.field_142048_a = p_i2348_2_;
  637. this.field_142046_b = p_i2348_3_;
  638. }
  639.  
  640. GroupData(boolean p_i2349_2_, boolean p_i2349_3_, Object p_i2349_4_)
  641. {
  642. this(p_i2349_2_, p_i2349_3_);
  643. }
  644. }
  645.  
  646. }
Advertisement
Add Comment
Please, Sign In to add comment