2015-12-28 19:09:51 -05:00
|
|
|
package WayofTime.bloodmagic.item;
|
|
|
|
|
2016-03-18 16:50:33 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-28 19:09:51 -05:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2016-03-18 16:50:33 -04:00
|
|
|
import net.minecraft.init.SoundEvents;
|
2015-12-28 19:09:51 -05:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-03-18 16:50:33 -04:00
|
|
|
import net.minecraft.util.SoundCategory;
|
2016-03-16 01:10:33 -07:00
|
|
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
2015-12-28 19:09:51 -05:00
|
|
|
|
2016-03-18 16:50:33 -04:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
import WayofTime.bloodmagic.ConfigHandler;
|
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
|
|
|
import WayofTime.bloodmagic.client.IVariantProvider;
|
2016-04-11 19:57:23 -04:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
2016-03-16 01:10:33 -07:00
|
|
|
|
|
|
|
public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
|
|
|
public ItemDaggerOfSacrifice()
|
|
|
|
{
|
2015-12-28 19:09:51 -05:00
|
|
|
super();
|
|
|
|
setUnlocalizedName(Constants.Mod.MODID + ".daggerOfSacrifice");
|
|
|
|
setCreativeTab(BloodMagic.tabBloodMagic);
|
|
|
|
setMaxStackSize(1);
|
|
|
|
setFull3D();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-12-30 15:34:40 -05:00
|
|
|
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
|
|
|
{
|
2015-12-28 19:09:51 -05:00
|
|
|
if (target == null || attacker == null || attacker.worldObj.isRemote || (attacker instanceof EntityPlayer && !(attacker instanceof EntityPlayerMP)))
|
|
|
|
return false;
|
|
|
|
|
2016-03-18 16:50:33 -04:00
|
|
|
if (target.isChild() || target instanceof EntityPlayer)
|
2015-12-28 19:09:51 -05:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (target.isDead || target.getHealth() < 0.5F)
|
|
|
|
return false;
|
|
|
|
|
2016-01-19 19:46:49 -08:00
|
|
|
String entityName = target.getClass().getSimpleName();
|
2015-12-28 19:09:51 -05:00
|
|
|
int lifeEssence = 500;
|
2016-01-19 19:46:49 -08:00
|
|
|
|
|
|
|
if (ConfigHandler.entitySacrificeValues.containsKey(entityName))
|
|
|
|
lifeEssence = ConfigHandler.entitySacrificeValues.get(entityName);
|
|
|
|
|
|
|
|
if (BloodMagicAPI.getEntitySacrificeValues().containsKey(entityName))
|
|
|
|
lifeEssence = BloodMagicAPI.getEntitySacrificeValues().get(entityName);
|
2015-12-30 15:34:40 -05:00
|
|
|
|
2016-04-17 00:03:53 -07:00
|
|
|
if (PlayerSacrificeHelper.findAndFillAltar(attacker.worldObj, target, lifeEssence, true))
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2016-04-24 10:06:28 -07:00
|
|
|
target.worldObj.playSound(null, target.posX, target.posY, target.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (target.worldObj.rand.nextFloat() - target.worldObj.rand.nextFloat()) * 0.8F);
|
2015-12-28 19:09:51 -05:00
|
|
|
target.setHealth(-1);
|
2016-04-11 19:57:23 -04:00
|
|
|
target.onDeath(BloodMagicAPI.getDamageSource());
|
2015-12-28 19:09:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-16 01:10:33 -07:00
|
|
|
@Override
|
2016-03-16 18:41:06 -04:00
|
|
|
public List<Pair<Integer, String>> getVariants()
|
|
|
|
{
|
2016-03-16 01:10:33 -07:00
|
|
|
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
|
|
|
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
|
|
|
|
return ret;
|
|
|
|
}
|
2015-12-28 19:09:51 -05:00
|
|
|
}
|