package com.zivilon.cinder_loe.items; import com.zivilon.cinder_loe.entity.corrupt.*; import lotr.common.LOTRLevelData; import lotr.common.entity.npc.*; import lotr.common.fac.LOTRFaction; import lotr.common.item.LOTRItemDagger; import lotr.common.item.LOTRItemSword; import lotr.common.item.LOTRMaterial; import lotr.common.item.LOTRWeaponStats; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; public class VoidDagger extends LOTRItemDagger { public VoidDagger(LOTRMaterial material) { super(material); } private LOTRFaction getFaction(EntityPlayer player) { LOTRFaction faction = LOTRLevelData.getData(player).getPledgeFaction(); if (faction == null) { faction = LOTRFaction.RUFFIAN; } return faction; } @Override public boolean hitEntity(ItemStack itemstack, EntityLivingBase target, EntityLivingBase attacker) { itemstack.damageItem(1, attacker); // Check if the target is dead and call the onKillEntity method if (target.getHealth() <= 0.0F) { onKillEntity(target, attacker); } return true; } public void onKillEntity(EntityLivingBase entityKilled, EntityLivingBase killer) { if (killer instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) killer; LOTRFaction faction = getFaction(player); entityKilled.worldObj.playSoundAtEntity(player, "mob.zombie.unfect", 1F,1F); if (!entityKilled.worldObj.isRemote && entityKilled instanceof LOTREntityOrc) { CorruptOrc corruptOrc = new CorruptOrc(entityKilled.worldObj); corruptOrc.copyLocationAndAnglesFrom(entityKilled); for (int i = 0; i < 4; i++) { ItemStack armor = entityKilled.getEquipmentInSlot(i + 1); // Armor slots corruptOrc.setCurrentItemOrArmor(i + 1, armor); } ItemStack mainWeapon = ((LOTREntityOrc) entityKilled).npcItemsInv.getMeleeWeapon(); // Main hand weapon corruptOrc.npcItemsInv.setIdleItem(mainWeapon); corruptOrc.npcItemsInv.setMeleeWeapon(mainWeapon); corruptOrc.setHealth(10); corruptOrc.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); entityKilled.worldObj.removeEntity(entityKilled); corruptOrc.onSpawnWithEgg((IEntityLivingData) null); entityKilled.worldObj.spawnEntityInWorld(corruptOrc); entityKilled.worldObj.playAuxSFXAtEntity(null, 1016, (int) corruptOrc.posX, (int) corruptOrc.posY, (int) corruptOrc.posZ, 0); } if (!entityKilled.worldObj.isRemote && entityKilled instanceof LOTREntityMan && !(entityKilled instanceof LOTREntityHobbit)) { CorruptMan entity = new CorruptMan(entityKilled.worldObj); entity.copyLocationAndAnglesFrom(entityKilled); for (int i = 0; i < 4; i++) { ItemStack armor = entityKilled.getEquipmentInSlot(i + 1); // Armor slots entity.setCurrentItemOrArmor(i + 1, armor); } ItemStack mainWeapon = ((LOTREntityMan) entityKilled).npcItemsInv.getMeleeWeapon(); // Main hand weapon entity.npcItemsInv.setIdleItem(mainWeapon); entity.npcItemsInv.setMeleeWeapon(mainWeapon); entity.setHealth(10); entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); entityKilled.worldObj.removeEntity(entityKilled); entity.onSpawnWithEgg((IEntityLivingData) null); entityKilled.worldObj.spawnEntityInWorld(entity); entityKilled.worldObj.playAuxSFXAtEntity(null, 1016, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); } } if (entityKilled instanceof LOTREntityHobbit) { CorruptHobbit entity = new CorruptHobbit(entityKilled.worldObj); entity.copyLocationAndAnglesFrom(entityKilled); for (int i = 0; i < 4; i++) { ItemStack armor = entityKilled.getEquipmentInSlot(i + 1); // Armor slots entity.setCurrentItemOrArmor(i + 1, armor); } ItemStack mainWeapon = ((LOTREntityHobbit) entityKilled).npcItemsInv.getMeleeWeapon(); // Main hand weapon entity.npcItemsInv.setIdleItem(mainWeapon); entity.npcItemsInv.setMeleeWeapon(mainWeapon); entity.setHealth(10); entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); entityKilled.worldObj.removeEntity(entityKilled); entity.onSpawnWithEgg((IEntityLivingData) null); entityKilled.worldObj.spawnEntityInWorld(entity); entityKilled.worldObj.playAuxSFXAtEntity(null, 1016, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); } if (!entityKilled.worldObj.isRemote && entityKilled instanceof LOTREntityEnt) { CorruptEnt entity = new CorruptEnt(entityKilled.worldObj); entity.copyLocationAndAnglesFrom(entityKilled); entityKilled.worldObj.removeEntity(entityKilled); entity.onSpawnWithEgg((IEntityLivingData) null); entity.setHealth(10); entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); entityKilled.worldObj.spawnEntityInWorld(entity); entityKilled.worldObj.playAuxSFXAtEntity(null, 1016, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); } if (!entityKilled.worldObj.isRemote && entityKilled instanceof LOTREntityElf) { CorruptElf entity = new CorruptElf(entityKilled.worldObj); entity.copyLocationAndAnglesFrom(entityKilled); for (int i = 0; i < 4; i++) { ItemStack armor = entityKilled.getEquipmentInSlot(i + 1); // Armor slots entity.setCurrentItemOrArmor(i + 1, armor); } entity.setHealth(10); entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); ItemStack mainWeapon = ((LOTREntityElf) entityKilled).npcItemsInv.getMeleeWeapon(); // Main hand weapon entity.npcItemsInv.setIdleItem(mainWeapon); entity.npcItemsInv.setMeleeWeapon(mainWeapon); entityKilled.worldObj.removeEntity(entityKilled); entity.onSpawnWithEgg((IEntityLivingData) null); entityKilled.worldObj.spawnEntityInWorld(entity); entityKilled.worldObj.playAuxSFXAtEntity(null, 1016, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); } if (!entityKilled.worldObj.isRemote && entityKilled instanceof LOTREntityDwarf) { CorruptDwarf entity = new CorruptDwarf(entityKilled.worldObj); entity.copyLocationAndAnglesFrom(entityKilled); for (int i = 0; i < 4; i++) { ItemStack armor = entityKilled.getEquipmentInSlot(i + 1); // Armor slots entity.setCurrentItemOrArmor(i + 1, armor); } ItemStack mainWeapon = ((LOTREntityDwarf) entityKilled).npcItemsInv.getMeleeWeapon(); // Main hand weapon entity.npcItemsInv.setIdleItem(mainWeapon); entity.npcItemsInv.setMeleeWeapon(mainWeapon); entity.setHealth(10); entity.addPotionEffect(new PotionEffect(Potion.regeneration.id, 9999, 0)); entityKilled.worldObj.removeEntity(entityKilled); entity.onSpawnWithEgg((IEntityLivingData) null); entityKilled.worldObj.spawnEntityInWorld(entity); entityKilled.worldObj.playAuxSFXAtEntity(null, 1016, (int) entity.posX, (int) entity.posY, (int) entity.posZ, 0); } } }