package com.alchemy.alchemy;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import java.util.UUID;
public class Needle extends ItemAxe
{
public Needle(Item.ToolMaterial material)
{
super(material);
this.maxStackSize = 1;
this.setCreativeTab(AlchemyBase.TabExorcism);
this.setTextureName(AlchemyBase.MODID + ":Needle");
this.setMaxDamage(material.getMaxUses());
}
@Override
public void registerIcons(IIconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(AlchemyBase.MODID + ":Needle");
}
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
{
if (entity instanceof EntityLivingBase)
{
EntityLivingBase entity_base = (EntityLivingBase) entity;
if (player.worldObj.rand.nextInt(5) == 0)
{
entity.playSound("random.explode", 1.0F, 1.0F);
entity_base.addPotionEffect(new PotionEffect(Potion.confusion.id, 0, 5));
player.inventory.consumeInventoryItem(AlchemyBase.Needle);
player.inventory.addItemStackToInventory(new ItemStack(AlchemyBase.NeedleWithBlood, 1));
for (int i = 0; i < 10; i++)
{
entity.worldObj.spawnParticle("reddust", entity.posX, entity.posY + 0.5, entity.posZ, 0.0D, 0.1D, 0.0D);
}
}
}
this.setDamage(stack, this.getDamage(stack) + 1);
if (this.getDamage(stack) >= this.getMaxDamage(stack))
{
player.inventory.consumeInventoryItem(this);
}
return true;
}
}