/*******************************************************************************
* AbyssalCraft
* Copyright (c) 2012 - 2017 Shinoow.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v3
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Contributors:
* Shinoow - implementation
******************************************************************************/
package com.shinoow.abyssalcraft.lib.item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import com.shinoow.abyssalcraft.lib.ACTabs;
/**
* Simple implementation of an Item with metadata subtypes.
* @author shinoow
*
*/
public class ItemMetadata extends Item {
private String[] names;
public ItemMetadata(String name, String...names){
setUnlocalizedName(name);
setCreativeTab(ACTabs.tabItems);
setMaxDamage(0);
setHasSubtypes(true);
this.names = names;
}
@Override
public int getMetadata(int meta) {
return meta;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item par1Item, CreativeTabs par2CreativeTab, NonNullList<ItemStack> par3List){
for(int i = 0; i < names.length; ++i)
par3List.add(new ItemStack(par1Item, 1, i));
}
@Override
public String getItemStackDisplayName(ItemStack par1ItemStack) {
return I18n.translateToLocal(getUnlocalizedName() + "." + names[par1ItemStack.getItemDamage()] + ".name");
}
}