GenuineSounds

Java - Client/Resource/ltd/genuine/effect/SwordEffect.java - Eclipse

Jun 13th, 2012
186
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. package ltd.genuine.effect;
  2.  
  3. import java.util.Random;
  4.  
  5. import ltd.genuine.element.EnumElement;
  6.  
  7. import net.minecraft.src.BiomeGenBase;
  8. import net.minecraft.src.DamageSource;
  9. import net.minecraft.src.EntityCreeper;
  10. import net.minecraft.src.EntityEnderman;
  11. import net.minecraft.src.EntityFlying;
  12. import net.minecraft.src.EntityGiantZombie;
  13. import net.minecraft.src.EntityLiving;
  14. import net.minecraft.src.EntitySkeleton;
  15. import net.minecraft.src.EntityZombie;
  16. import net.minecraft.src.EnumCreatureType;
  17. import net.minecraft.src.ItemStack;
  18.  
  19. public class SwordEffect implements IEffect {
  20.  
  21. public float pointsPer;
  22.  
  23. public SwordEffect(float pointsPer) {
  24. this.pointsPer = pointsPer;
  25. }
  26.  
  27. public int hitValue(float value) {
  28. return (int) (value / pointsPer);
  29. }
  30.  
  31. public void process(ItemStack itemstack, EntityLiving target, EntityLiving source) {
  32. if (itemstack != null && itemstack.stackTagCompound != null) {
  33. for (EnumElement type : EnumElement.values()) {
  34. float value = itemstack.stackTagCompound.getFloat(type.getName());
  35. if (value == 0)
  36. continue;
  37. switch (type) {
  38. case FIRE:
  39. if (target.isImmuneToFire()) {
  40. if (value > 0)
  41. target.heal(hitValue(value));
  42. else
  43. Damage.applyDirectDamage(target, Damage.Water, -hitValue(value));
  44. } else
  45. Damage.applyDirectDamage(target, Damage.Fire, hitValue(value));
  46. break;
  47. case WIND:
  48. if (target instanceof EntityFlying) {
  49. if (value < 0)
  50. target.heal(-hitValue(value));
  51. else
  52. Damage.applyDirectDamage(target, Damage.Wind, hitValue(value));
  53. }
  54. break;
  55. case HEAVEN:
  56. boolean deathy = false;
  57. for (int i = 0; i < EnumCreatureType.values().length; i++) {
  58. if (BiomeGenBase.hell.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
  59. deathy = true;
  60. break;
  61. }
  62. }
  63. if (deathy || target instanceof EntityZombie || target instanceof EntityGiantZombie || target instanceof EntityEnderman || target instanceof EntitySkeleton) {
  64. if (value < 0)
  65. target.heal(-hitValue(value));
  66. else
  67. Damage.applyDirectDamage(target, Damage.Heaven, hitValue(value));
  68. }
  69. break;
  70. case WATER:
  71. if (target.isImmuneToFire() || target instanceof EntityCreeper) {
  72. if (value < 0)
  73. target.heal(-hitValue(value));
  74. else
  75. Damage.applyDirectDamage(target, Damage.Water, hitValue(value));
  76. }
  77. break;
  78. case EARTH:
  79. boolean watery = false;
  80. for (int i = 0; i < EnumCreatureType.values().length; i++) {
  81. if (BiomeGenBase.ocean.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
  82. watery = true;
  83. break;
  84. }
  85. if (BiomeGenBase.river.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
  86. watery = true;
  87. break;
  88. }
  89. }
  90. if (watery) {
  91. if (value < 0)
  92. target.heal(-hitValue(-value));
  93. else
  94. Damage.applyDirectDamage(target, Damage.Earth, hitValue(value));
  95. }
  96. break;
  97. case HELL:
  98. if (new Random().nextFloat() < value / 1000f)
  99. Damage.applyDirectDamage(target, Damage.Hell, 1000);
  100. break;
  101. }
  102. }
  103. }
  104. }
  105. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment