GenuineSounds

Genuine Sword effects.

Jun 12th, 2012
202
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.89 KB | None | 0 0
  1. /**
  2.  * Sword effects:
  3.  * Fire - Does fire damage / Heals entities immune to fire.
  4.  * Wind - Extra damage to flying creatures.
  5.  * Heaven - Extra damage to nether creatures, Endermen, skeletons, and zombies.
  6.  * Water - Extra damage to blazes and fiery creatures.
  7.  * Earth - Extra damage to creepers and water creatures.
  8.  * Hell - Chance to cause 1000 damage.
  9.  */
  10. @Override
  11. public boolean hitEntity(ItemStack itemstack, EntityLiving target, EntityLiving source) {
  12.     if (itemstack.getItemDamage() > 0)
  13.         itemstack.setItemDamage(itemstack.getItemDamage() - 1);
  14.     if (itemstack != null && itemstack.stackTagCompound != null) {
  15.         for (EnumElement type : EnumElement.values()) {
  16.             float value = itemstack.stackTagCompound.getFloat(type.getName());
  17.             if (value == 0)
  18.                 continue;
  19.             switch (type) {
  20.                 case FIRE:
  21.                     if (target.isImmuneToFire) {
  22.                         if (value > 0)
  23.                             target.heal(hitValue(value));
  24.                         else
  25.                             target.attackEntityFrom(DamageSource.drown, hitValue(value));
  26.                     } else
  27.                         target.attackEntityFrom(DamageSource.onFire, hitValue(value));
  28.                     break;
  29.                 case WIND:
  30.                     if (target instanceof EntityFlying)
  31.                         if (value < 0)
  32.                             target.heal(hitValue(value));
  33.                         else
  34.                             target.attackEntityFrom(DamageSource.fall, hitValue(value));
  35.                     break;
  36.                 case HEAVEN:
  37.                     boolean deathy = false;
  38.                     for (int i = 0; i < EnumCreatureType.values().length; i++) {
  39.                         if (BiomeGenBase.hell.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
  40.                             deathy = true;
  41.                             break;
  42.                         }
  43.                     }
  44.                     if (deathy || target instanceof EntityZombie || target instanceof EntityGiantZombie || target instanceof EntityEnderman || target instanceof EntitySkeleton)
  45.                         if (value < 0)
  46.                             target.heal(hitValue(value));
  47.                         else
  48.                             target.attackEntityFrom(DamageSource.outOfWorld, hitValue(value));
  49.                     break;
  50.                 case WATER:
  51.                     if (target.isImmuneToFire || target instanceof EntityCreeper)
  52.                         if (value < 0)
  53.                             target.heal(hitValue(value));
  54.                         else
  55.                             target.attackEntityFrom(DamageSource.drown, hitValue(value));
  56.                     break;
  57.                 case EARTH:
  58.                     boolean watery = false;
  59.                     for (int i = 0; i < EnumCreatureType.values().length; i++) {
  60.                         if (BiomeGenBase.ocean.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
  61.                             watery = true;
  62.                             break;
  63.                         }
  64.                         if (BiomeGenBase.river.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
  65.                             watery = true;
  66.                             break;
  67.                         }
  68.                     }
  69.                     if (watery)
  70.                         if (value < 0)
  71.                             target.heal(hitValue(value));
  72.                         else
  73.                             target.attackEntityFrom(DamageSource.starve, hitValue(value));
  74.                     break;
  75.                 case HELL:
  76.                     if (rnd.nextFloat() < value / 1000f)
  77.                         target.attackEntityFrom(DamageSource.magic, 1000);
  78.                        
  79.             }
  80.         }
  81.     }
  82.     target.attackEntityFrom(new DamageSource("Genuine"), (int) genDamage(itemstack));
  83.     return true;
  84. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment