Skip to content

Instantly share code, notes, and snippets.

Created July 29, 2016 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6d728ea672bc5608604b88b7263a7dfa to your computer and use it in GitHub Desktop.
Save anonymous/6d728ea672bc5608604b88b7263a7dfa to your computer and use it in GitHub Desktop.
package com.bigsis.spookjams.init; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".
import com.bigsis.spookjams.Reference; //Import this to recognize our custom Reference.java class.
import com.bigsis.spookjams.items.ItemCheese; //Import this to recognize our custom ItemCheese.java class.
import com.bigsis.spookjams.items.ItemGFBread; //Import this to recognize our custom ItemGFBread.java class.
import net.minecraft.client.Minecraft; //Imported to allow the Minecraft client to be recognized
import net.minecraft.client.renderer.block.model.ModelResourceLocation; //Imported to allow the ModelResourceLocation class to be recognized.
import net.minecraft.item.Item; //Imported to allow for Minecraft objects to be registered.
import net.minecraftforge.fml.common.registry.GameRegistry; //Imported to recognize the use of the GameRegistry class.
public class ModItems
{
public static Item cheese; //This is the name of our new custom item.
public static Item gf_bread; //This is the name of our second custom item.
public static void init() //This method will initialize this object.
{
cheese = new ItemCheese(); //Set the new Item to be a new instance of our custom cheese object as defined in ItemCheese.java.
gf_bread = new ItemGFBread(); //Set the second new Item to be a new instance of our gluten-free bread object as defined in ItemGFBread.java.
}
public static void register() //This will register the item into the game.
{
GameRegistry.register(cheese); //Register our custom item in Minecraft using the new Item object we initiated above.
GameRegistry.register(gf_bread); //Register our second custom item.
}
public static void registerRenders() //This will contain all the calls to register the render for each item.
{
registerRender(cheese); //Call the private method below.
registerRender(gf_bread); //Call the private method below.
}
private static void registerRender(Item item) //This is the new item object that you will register into Minecraft.
{
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); //Register this new item by referencing its system name, and specifying that it will be an Inventory item.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment