2014-11-10 16:47:04 +01:00
|
|
|
package ellpeck.thingycraft.items;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
import ellpeck.thingycraft.ThingyCraft;
|
|
|
|
import ellpeck.thingycraft.Util;
|
|
|
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.IIcon;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class ItemGem extends Item {
|
|
|
|
|
2014-12-03 21:55:53 +01:00
|
|
|
public final IIcon[] textures;
|
2014-11-10 16:47:04 +01:00
|
|
|
|
|
|
|
public ItemGem(){
|
2014-12-03 21:55:53 +01:00
|
|
|
textures = new IIcon[Util.gemList.size()];
|
2014-11-10 16:47:04 +01:00
|
|
|
this.setHasSubtypes(true);
|
|
|
|
this.setCreativeTab(CreativeTabs.tabBrewing);
|
|
|
|
this.setUnlocalizedName("itemGem");
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
|
|
|
if(Util.isShiftPressed()){
|
2014-12-03 21:55:53 +01:00
|
|
|
for(int i = 0; i < Util.gemList.size(); i++){
|
|
|
|
if(this.getDamage(stack) == i) list.add(StatCollector.translateToLocal("tooltip.gem" + Util.gemList.get(i).name.substring(5) + ".desc"));
|
2014-11-10 16:47:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
list.add(Util.shiftForInfo());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getUnlocalizedName(ItemStack stack){
|
2014-12-03 21:55:53 +01:00
|
|
|
return this.getUnlocalizedName() + Util.gemList.get(stack.getItemDamage()).name.substring(5);
|
2014-11-10 16:47:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void getSubItems(Item item, CreativeTabs tabs, List list){
|
2014-12-03 21:55:53 +01:00
|
|
|
for (int i = 0; i < Util.gemList.size(); i++) {
|
2014-11-10 16:47:04 +01:00
|
|
|
list.add(new ItemStack(item, 1, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public IIcon getIconFromDamage(int par1){
|
|
|
|
return textures[par1];
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
public void registerIcons(IIconRegister iconReg){
|
2014-12-03 21:55:53 +01:00
|
|
|
for (int i = 0; i < Util.gemList.size(); i++) {
|
|
|
|
textures[i] = iconReg.registerIcon(ThingyCraft.MOD_ID + ":" + this.getUnlocalizedName().substring(5) + Util.gemList.get(i).name.substring(5));
|
2014-11-10 16:47:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-03 21:55:53 +01:00
|
|
|
}
|