Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Sword effects:
- * Fire - Does fire damage / Heals entities immune to fire.
- * Wind - Extra damage to flying creatures.
- * Heaven - Extra damage to nether creatures, Endermen, skeletons, and zombies.
- * Water - Extra damage to blazes and fiery creatures.
- * Earth - Extra damage to creepers and water creatures.
- * Hell - Chance to cause 1000 damage.
- */
- @Override
- public boolean hitEntity(ItemStack itemstack, EntityLiving target, EntityLiving source) {
- if (itemstack.getItemDamage() > 0)
- itemstack.setItemDamage(itemstack.getItemDamage() - 1);
- 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
- target.attackEntityFrom(DamageSource.drown, hitValue(value));
- } else
- target.attackEntityFrom(DamageSource.onFire, hitValue(value));
- break;
- case WIND:
- if (target instanceof EntityFlying)
- if (value < 0)
- target.heal(hitValue(value));
- else
- target.attackEntityFrom(DamageSource.fall, 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
- target.attackEntityFrom(DamageSource.outOfWorld, hitValue(value));
- break;
- case WATER:
- if (target.isImmuneToFire || target instanceof EntityCreeper)
- if (value < 0)
- target.heal(hitValue(value));
- else
- target.attackEntityFrom(DamageSource.drown, 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
- target.attackEntityFrom(DamageSource.starve, hitValue(value));
- break;
- case HELL:
- if (rnd.nextFloat() < value / 1000f)
- target.attackEntityFrom(DamageSource.magic, 1000);
- }
- }
- }
- target.attackEntityFrom(new DamageSource("Genuine"), (int) genDamage(itemstack));
- return true;
- }
Advertisement