Skip to content

Instantly share code, notes, and snippets.

@LionZXY
Created July 7, 2015 08:15
Show Gist options
  • Save LionZXY/f175dbfaa6b5bf7739da to your computer and use it in GitHub Desktop.
Save LionZXY/f175dbfaa6b5bf7739da to your computer and use it in GitHub Desktop.
package ru.nord.common.items;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import ru.nord.NordItems;
import ru.nord.NordTabs;
import ru.nord.common.lib.helpers.RegisterHelper;
import java.util.List;
/**
* Created by nikit_000 on 06.07.2015.
*/
public class ItemDust extends Item {
public static String[] namedust = new String[]{"iron","gold","diamond","glass"};
public static void preInit(){
NordItems.dustItem = new ItemDust().setUnlocalizedName("dust");
RegisterHelper.registerMetadataItem(NordItems.dustItem,"dust","dust",namedust);
}
public ItemDust()
{
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setCreativeTab(NordTabs.tabGeneral);
}
public String getUnlocalizedName(ItemStack stack)
{
return super.getUnlocalizedName() + "." + stack.getMetadata();
}
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
{
for (int i = 0; i < namedust.length; ++i)
{
subItems.add(new ItemStack(itemIn, 1, i));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment