84 lines
2.4 KiB
Java
84 lines
2.4 KiB
Java
package mods.tinker.tconstruct.items;
|
|
|
|
import java.util.List;
|
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.EnumRarity;
|
|
import net.minecraft.item.ItemFood;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.potion.Potion;
|
|
import net.minecraft.potion.PotionEffect;
|
|
import net.minecraft.util.Icon;
|
|
import net.minecraft.world.World;
|
|
import cpw.mods.fml.relauncher.Side;
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
public class GoldenHead extends ItemFood
|
|
{
|
|
public GoldenHead(int par1, int par2, float par3, boolean par4)
|
|
{
|
|
super(par1, par2, par3, par4);
|
|
this.setHasSubtypes(true);
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public boolean hasEffect(ItemStack par1ItemStack)
|
|
{
|
|
return par1ItemStack.getItemDamage() > 0;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
/**
|
|
* Return an item rarity from EnumRarity
|
|
*/
|
|
public EnumRarity getRarity(ItemStack par1ItemStack)
|
|
{
|
|
return par1ItemStack.getItemDamage() == 0 ? EnumRarity.rare : EnumRarity.epic;
|
|
}
|
|
|
|
protected void onFoodEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
|
|
{
|
|
if (par1ItemStack.getItemDamage() > 0)
|
|
{
|
|
if (!par2World.isRemote)
|
|
{
|
|
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.regeneration.id, 600, 3));
|
|
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.resistance.id, 6000, 0));
|
|
par3EntityPlayer.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 6000, 0));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
super.onFoodEaten(par1ItemStack, par2World, par3EntityPlayer);
|
|
}
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
/**
|
|
* returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
|
|
*/
|
|
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
|
{
|
|
par3List.add(new ItemStack(par1, 1, 0));
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
@Override
|
|
public void registerIcons(IconRegister iconRegister)
|
|
{
|
|
this.itemIcon = iconRegister.registerIcon("tinker:skull_char_gold");
|
|
/*this.icons = new Icon[textureNames.length];
|
|
|
|
for (int i = 0; i < this.icons.length; ++i)
|
|
{
|
|
this.icons[i] = iconRegister.registerIcon("tinker:"+textureNames[i]);
|
|
}*/
|
|
}
|
|
}
|