Last active
October 17, 2015 18:48
-
-
Save tinkerstudent/2b21ec70fe4fe91a2098 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.tinkeracademy.rvergis; | |
| import net.minecraft.client.Minecraft; | |
| import net.minecraft.client.renderer.entity.RenderItem; | |
| import net.minecraft.client.resources.model.ModelBakery; | |
| import net.minecraft.client.resources.model.ModelResourceLocation; | |
| import net.minecraft.creativetab.CreativeTabs; | |
| import net.minecraft.item.Item; | |
| import net.minecraftforge.fml.common.registry.GameRegistry; | |
| public class ItemKey extends Item { | |
| private static final String ORANGE_KEY = "orange_key"; | |
| private static final String GREEN_KEY = "green_key"; | |
| private static final String RED_KEY = "red_key"; | |
| private static final String PURPLE_KEY = "purple_key"; | |
| private static final String YELLOW_KEY = "yellow_key"; | |
| private String name = "key"; | |
| private String[] names = { ORANGE_KEY, GREEN_KEY, RED_KEY, PURPLE_KEY, YELLOW_KEY }; | |
| public ItemKey() { | |
| GameRegistry.registerItem(this, name); | |
| setUnlocalizedName(MyItemsMod.MODID + "_" + name); | |
| setHasSubtypes(true); | |
| setCreativeTab(CreativeTabs.tabMisc); | |
| ModelBakery.addVariantName(this, MyItemsMod.MODID + ":" + ORANGE_KEY, MyItemsMod.MODID + ":" + GREEN_KEY, | |
| MyItemsMod.MODID + ":" + RED_KEY, MyItemsMod.MODID + ":" + PURPLE_KEY, | |
| MyItemsMod.MODID + ":" + YELLOW_KEY); | |
| } | |
| public void init() { | |
| registerKey((ItemKey) this, 0, ORANGE_KEY); | |
| registerKey((ItemKey) this, 1, GREEN_KEY); | |
| registerKey((ItemKey) this, 2, RED_KEY); | |
| registerKey((ItemKey) this, 3, PURPLE_KEY); | |
| registerKey((ItemKey) this, 4, YELLOW_KEY); | |
| } | |
| public void registerKey(ItemKey key, int metadata, String fileName) { | |
| RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); | |
| renderItem.getItemModelMesher().register(key, metadata, | |
| new ModelResourceLocation(MyItemsMod.MODID + ':' + fileName, "inventory")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment