Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ltd.genuine.effect;
- import java.util.Random;
- import ltd.genuine.element.EnumElement;
- import net.minecraft.src.BiomeGenBase;
- import net.minecraft.src.DamageSource;
- import net.minecraft.src.EntityCreeper;
- import net.minecraft.src.EntityEnderman;
- import net.minecraft.src.EntityFlying;
- import net.minecraft.src.EntityGiantZombie;
- import net.minecraft.src.EntityLiving;
- import net.minecraft.src.EntitySkeleton;
- import net.minecraft.src.EntityZombie;
- import net.minecraft.src.EnumCreatureType;
- import net.minecraft.src.ItemStack;
- public class SwordEffect implements IEffect {
- public float pointsPer;
- public SwordEffect(float pointsPer) {
- this.pointsPer = pointsPer;
- }
- public int hitValue(float value) {
- return (int) (value / pointsPer);
- }
- public void process(ItemStack itemstack, EntityLiving target, EntityLiving source) {
- if (itemstack != null && itemstack.stackTagCompound != null) {
- for (EnumElement type : EnumElement.values()) {
- float value = itemstack.stackTagCompound.getFloat(type.getName());
- if (value == 0)
- continue;
- switch (type) {
- case FIRE:
- if (target.isImmuneToFire()) {
- if (value > 0)
- target.heal(hitValue(value));
- else
- Damage.applyDirectDamage(target, Damage.Water, -hitValue(value));
- } else
- Damage.applyDirectDamage(target, Damage.Fire, hitValue(value));
- break;
- case WIND:
- if (target instanceof EntityFlying) {
- if (value < 0)
- target.heal(-hitValue(value));
- else
- Damage.applyDirectDamage(target, Damage.Wind, hitValue(value));
- }
- break;
- case HEAVEN:
- boolean deathy = false;
- for (int i = 0; i < EnumCreatureType.values().length; i++) {
- if (BiomeGenBase.hell.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
- deathy = true;
- break;
- }
- }
- if (deathy || target instanceof EntityZombie || target instanceof EntityGiantZombie || target instanceof EntityEnderman || target instanceof EntitySkeleton) {
- if (value < 0)
- target.heal(-hitValue(value));
- else
- Damage.applyDirectDamage(target, Damage.Heaven, hitValue(value));
- }
- break;
- case WATER:
- if (target.isImmuneToFire() || target instanceof EntityCreeper) {
- if (value < 0)
- target.heal(-hitValue(value));
- else
- Damage.applyDirectDamage(target, Damage.Water, hitValue(value));
- }
- break;
- case EARTH:
- boolean watery = false;
- for (int i = 0; i < EnumCreatureType.values().length; i++) {
- if (BiomeGenBase.ocean.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
- watery = true;
- break;
- }
- if (BiomeGenBase.river.getSpawnableList(EnumCreatureType.values()[i]).contains(target)) {
- watery = true;
- break;
- }
- }
- if (watery) {
- if (value < 0)
- target.heal(-hitValue(-value));
- else
- Damage.applyDirectDamage(target, Damage.Earth, hitValue(value));
- }
- break;
- case HELL:
- if (new Random().nextFloat() < value / 1000f)
- Damage.applyDirectDamage(target, Damage.Hell, 1000);
- break;
- }
- }
- }
- }
- }
Advertisement