/** * Copyright (c) 22/Feb/2015 Davide Cossu & Matthew Albrecht. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 3 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, see <http://www.gnu.org/licenses>. */ package com.minestellar.moon.items; import java.util.List; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumRarity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import com.minestellar.core.MinestellarCore; import com.minestellar.core.proxy.ClientProxyCore; import com.minestellar.moon.MinestellarMoon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemBasicMoon extends Item { private static String[] names = {}; protected IIcon[] icons = new IIcon[ItemBasicMoon.names.length]; public ItemBasicMoon() { super(); this.setMaxDamage(0); this.setHasSubtypes(true); } @SideOnly(Side.CLIENT) @Override public CreativeTabs getCreativeTab() { return MinestellarCore.stellarItemsTab; } @Override @SideOnly(Side.CLIENT) public EnumRarity getRarity(ItemStack par1ItemStack) { return ClientProxyCore.stellarItem; } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { int i = 0; for (String name : ItemBasicMoon.names) { this.icons[i++] = iconRegister.registerIcon(MinestellarMoon.TEXTURE_PREFIX + name); } } @Override public IIcon getIconFromDamage(int damage) { if (this.icons.length > damage) { return this.icons[damage]; } return super.getIconFromDamage(damage); } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) { for (int i = 0; i < ItemBasicMoon.names.length; i++) { par3List.add(new ItemStack(par1, 1, i)); } } @Override public String getUnlocalizedName(ItemStack par1ItemStack) { if (this.icons.length > par1ItemStack.getItemDamage()) { return "item." + ItemBasicMoon.names[par1ItemStack.getItemDamage()]; } return "unnamed"; } @Override public int getMetadata(int par1) { return par1; } }