Skip to content

Instantly share code, notes, and snippets.

@Jezza
Created November 28, 2013 16:08
Show Gist options
  • Save Jezza/7694238 to your computer and use it in GitHub Desktop.
Save Jezza/7694238 to your computer and use it in GitHub Desktop.
package slade.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import slade.Main;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class AllFood extends ItemFood
{
@SideOnly(Side.CLIENT)
private Icon[] icons;
public static final String[] upgrades = new String[]{"rBacon", "cBacon", "yolk", "cEgg", "fBread", "cheese", "butter", "strawberry", "milkshake", "donut"};
public AllFood(int id, int par2, float par3, boolean par4)
{
super(id, par2, par3, par4);
this.setCreativeTab(CreativeTabs.tabFood);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister icon)
{
icons = new Icon[10];
for(int i=0;i<icons.length;i++)
{
icons[i] = icon.registerIcon(Main.modid + ":"+ (this.getUnlocalizedName().substring(5)) + i);
}
}
public Icon getIconFromDamage(int meta)
{
return icons[meta];
}
@SideOnly(Side.CLIENT)
public void getSubItems(int id, CreativeTabs tab, List list)
{
for(int x=0;x<10;x++)
{
list.add(new ItemStack(this, 1, x));
}
}
public String getUnlocalizedName(ItemStack itemstack)
{
return super.getUnlocalizedName() + ":" + upgrades[MathHelper.clamp_int(itemstack.getItemDamage(), 0, 15)];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment