/xolova/divinerpg/entities/overworld/mobs/EntityJungleSpider.java

https://bitbucket.org/Hologuardian/divinerpg · Java · 114 lines · 82 code · 20 blank · 12 comment · 6 complexity · 2f5f0bc931649df634ecec9d69f3c930 MD5 · raw file

  1. package xolova.divinerpg.entities.overworld.mobs;
  2. import net.minecraft.enchantment.EnchantmentHelper;
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.EntityLiving;
  5. import net.minecraft.entity.monster.EntitySpider;
  6. import net.minecraft.potion.Potion;
  7. import net.minecraft.potion.PotionEffect;
  8. import net.minecraft.util.DamageSource;
  9. import net.minecraft.util.MathHelper;
  10. import net.minecraft.world.World;
  11. import xolova.divinerpg.utils.helpers.item.OverworldItemHelper;
  12. public class EntityJungleSpider extends EntitySpider
  13. {
  14. public EntityJungleSpider(World var1)
  15. {
  16. super(var1);
  17. this.texture = "/mob/junglespider.png";
  18. this.setSize(1.4F, 0.9F);
  19. }
  20. public int getAttackStrength(Entity var1)
  21. {
  22. return 16;
  23. }
  24. public int getMaxHealth()
  25. {
  26. return 120;
  27. }
  28. public boolean attackEntityAsMob(Entity par1Entity)
  29. {
  30. int var2 = this.getAttackStrength(par1Entity);
  31. if (this.isPotionActive(Potion.damageBoost))
  32. {
  33. var2 += 3 << this.getActivePotionEffect(Potion.damageBoost).getAmplifier();
  34. }
  35. if (this.isPotionActive(Potion.weakness))
  36. {
  37. var2 -= 2 << this.getActivePotionEffect(Potion.weakness).getAmplifier();
  38. }
  39. int var3 = 0;
  40. if (par1Entity instanceof EntityLiving)
  41. {
  42. var2 += EnchantmentHelper.getEnchantmentModifierLiving(this, (EntityLiving)par1Entity);
  43. var3 += EnchantmentHelper.getKnockbackModifier(this, (EntityLiving)par1Entity);
  44. }
  45. boolean var4 = par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), var2);
  46. if (var4)
  47. {
  48. if (var3 > 0)
  49. {
  50. par1Entity.addVelocity((double)(-MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F) * (float)var3 * 0.5F), 0.1D, (double)(MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F) * (float)var3 * 0.5F));
  51. this.motionX *= 0.6D;
  52. this.motionZ *= 0.6D;
  53. }
  54. ((EntityLiving)par1Entity).addPotionEffect(new PotionEffect(Potion.poison.id, var2 * 20, 0));
  55. int var5 = EnchantmentHelper.getFireAspectModifier(this);
  56. if (var5 > 0)
  57. {
  58. par1Entity.setFire(var5 * 4);
  59. }
  60. }
  61. return var4;
  62. }
  63. /**
  64. * Returns the sound this mob makes while it's alive.
  65. */
  66. protected String getLivingSound()
  67. {
  68. return "mob.RPG.JungleSpider";
  69. }
  70. /**
  71. * Returns the item ID for the item the mob drops on death.
  72. */
  73. protected int getDropItemId()
  74. {
  75. return OverworldItemHelper.jungleShard.itemID;
  76. }
  77. /**
  78. * Drop 0-2 items of this living's type
  79. */
  80. protected void dropFewItems(boolean var1, int var2)
  81. {
  82. int var3 = this.rand.nextInt(4 + var2);
  83. int var4;
  84. this.dropItem(OverworldItemHelper.jungleShard.itemID, var3);
  85. }
  86. /**
  87. * Checks to make sure the light is not too bright where the mob is spawning
  88. */
  89. @Override
  90. protected boolean isValidLightLevel()
  91. {
  92. return true;
  93. }
  94. }