Skip to content

Commit

Permalink
Preparations for some Crafting Items
Browse files Browse the repository at this point in the history
  • Loading branch information
founderio committed Sep 9, 2014
1 parent 14a1b84 commit dc061dc
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions common/founderio/chaoscrystal/items/ItemMaterial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package founderio.chaoscrystal.items;

import java.util.List;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import founderio.chaoscrystal.Constants;

public class ItemMaterial extends Item {

private IIcon[] iconList;

public ItemMaterial() {
super();
this.setMaxDamage(0);
this.setHasSubtypes(true);
}

@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage(int meta) {

if (meta < 0 || meta >= iconList.length) {
meta = 0;
}

return iconList[meta];
}

public String getUnlocalizedName(ItemStack itemStack) {
int i = itemStack.getItemDamage();

if (i < 0 || i >= Constants.METALIST_MATERIAL.length) {
i = 0;
}

return super.getUnlocalizedName() + "." + Constants.METALIST_MATERIAL[i];
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister ir) {
iconList = new IIcon[Constants.METALIST_MATERIAL.length];
for (int i = 0; i < Constants.METALIST_MATERIAL.length; i++) {
iconList[i] = ir.registerIcon(Constants.MOD_ID + ":material." + Constants.METALIST_MATERIAL[i]);
}
}

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs creativeTab, List list) {
for (int i = 0; i < Constants.METALIST_MATERIAL.length; i++) {
list.add(new ItemStack(item, 1, i));
}
}
}

0 comments on commit dc061dc

Please sign in to comment.