FANDOM


Introduction Edit

Creating items in 1.9 has changed quite a lot from creating items in 1.7.10. Here, we'll teach you the best way to go around doing things!

  • Init
  • Creating the Item
  • Activating the scripts
  • Textures
  • Naming the item

Let's get started!

Basic Items Edit

Init Edit

If you have yet to figure it out, init stands for Initiation, in which we will be creating all of our items. The first thing we need to go is right click on your modname, in which mine is com.fire.tutorialmod. Press NEW, press FOLDER. The name of this folder is going to be called "Init". Now, right click on Init. Press NEW, press CLASS. For the name of this class, we are going to call it "InitItems".

Now we are going to create some classes. Each of which will be listed below. Within the brackets, you are going to want to type all three of the below...

Code1-0

The first one we created, init(), will be where we tell the game what our items will 'be'. The reason we put register(); in it is because we need to call the next one, register(). This one will basically register our items into the game. Now, each item has to be 'rendered' in the players inventory, so that's why we created the registerRenders() class. The last class is what we are going to do right now!

The reason we have created this class called registerRender(), is because here we will be telling minecraft how it's going to render an item. Within the brackets of registerRender(), put the line below...

ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));

First, we call ModelLoader to setCustomModelResource location. We type 'item', because that's going to be the item we're rendering. We put 0, because we're not currently making a MetaData block. Then, we need to create a new ModelResourceLocation. In here we get the registeryName, not the unlocalizedName. I'll explain registeryName in a minute, but now we need to get started on creating out first item! Before we do, make sure to press CTRL + SHIFT + O to import everything, and then CTRL + S to save. (It should only import one thing: net.minecraft.item.Item;)

Creating the item Edit

Now that we have our init folder all set up, we need to create the item. Right after the InitItems bracket but right before the init() class, we need to write the line below...

public static Item <ITEMNAME>;

If you haven't already, make sure to import Item. I am going to be calling my item itemTest, so my line will look like this, public static Item itemTest;.

Now that our item is called, we need to go into our init() class. Right above register();, we will type the line below...

<ITEMNAME> = new <ITEMNAME>("<ITEMNAME>");

So, my line will look like so, itemTest = new itemTest("itemTest");. You will get an error over new itemTest; do not worry! After the last bracket, type .setCreativeTab(). Within the brackets of set creative tab, you will type CreativeTabs.<TABNAME>. If you are using Eclipse, then it should give you a list of all the creative tabs. For our item, we'll set it as tabMisc. We will fix this in a second. Hover over the itemTest part of new itemTest, and look for the one that says Create class 'itemTest' (You may have to scroll down). Click on that, and now we are going to change some things on this box. In the Package area, mine looks like this, com.fire.tutorialmod.Init. Your should look something similar to this. Replace the .Init part with .Items.<ITEMNAME>. So, mine would look like this, com.fire.tutorialmod.Items.itemTest. Go ahead and press finish. Now we have this new area to play around with! Within the brackets, type the three lines below...

public itemTest(String name){
     this.setUnlocalizedName(name);
     this.setRegistryName(Strings.MODID, name);
}

Now your item class should look something like this... (Ignore the errors in InitItems)

Code2-0

Before we move on, make sure to press CTRL + SHIFT + O to import everything, and CTRL + S to save. Now we are finished in our new itemclass, go ahead and go back to InitItems. Within the brackets of register(), type the line below...

GameRegistry.register(itemTest);

Now we have registered out item, we need to register our render. Under registerRenders(), type the line below...

registerRender(itemTest);

Now we have completed our item (after importing everything and saving), but it has no textures, and it's not being called to be rendered. We shall fix that now!

Activating the scripts Edit

There are only two things we need to do here. First, let's go back into our MainRegistry. Scroll down to your Preload section. Above proxy.registerRenderInfo(), we will type the line below...

InitItems.init()

Make sure to import our InitItems. Once you have done it successfully, the init() should be italicized. Now we are finished in our MainRegistry, let's run over to our ClientProxy (don't forget to save).

In our ClientProxy, within the registerRenderInfo() , we need to type the line below...

InitItems.registerRenders();

Make sure to import the correct one, and we have finished activating our scripts!

Textures Edit

Now we have almost completed our item, but now we need to make some textures! All the way at the top, you should see something that says src/main/java. You should also see a src/main/resources. We are now going to go into the resources one! Right click on src/main/resources, press NEW, press FOLDER. We are going to name this folder assets. On the assets folder, right click. Press NEW, press FOLDER. We are going to name this folder your modid. For me, it will be tutorialmod. Now, once again, right click on this folder, press NEW, press FOLDER. We are going to name this folder models. Now, one more time, right click on models, press NEW, press FOLDER, and name this one item. Right click on item, press NEW, and this time, we are going to press FILE. Name this file whatever your item name was. For me, it's going to be itemTest. But here's the catch, add .json to the end of your file. So when you press finish, you should now have a file called itemTest.json. Now you are going to copy the below into your file.

{
    "parent": "item/generated",
    "textures": {
        "layer0": "<MODID>:items/<ITEMNAME>"
    },
    "display": {
        "thirdperson": {
            "rotation": [ -90, 0, 0 ],
            "translation": [ 0, 1, -3 ],
            "scale": [ 0.55, 0.55, 0.55 ]
        },
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 1.13, 3.2, 1.13 ],
            "scale": [ 0.68, 0.68, 0.68 ]
        }
    }
}

Replace <MODID> with your modid, in which mine is tutorialmod. Replace <ITEMNAME> with the name of your item, in which mine will be itemTest. Now, we're going to create some more folders, YAY!

Right click on tutorialmod or whatever you named the folder, and press NEW, FOLDER. Name this folder "textures". Create a new folder in textures called "items". Now in here you place your texture. Make sure it is a .png file, and is divisible by 16 in size. So sizes like 248x211 won't work. Sizes above 256x256 will cause many games to lag, depending on how many items. The suggested sizes would be 16x16, 32x32, 64x64, and at most 128x128. Make sure your file is the same name as your itemname. So if I named my item 'itemApple2', then your texture cannot be 'apple2item.png', it has to be 'itemApple2.png'. Now you have successfully added items!

Naming the item Edit

Very quickly, we are going to name our item. Right click on your tutorialmod folder or whatever you named the folder, and create a new folder. Name that folder "lang". Create a new file in lang, and call it "en_US.lang". In here, we are going to type item.testItem.name=Test Item. YOU CANNOT ADD ANY SPACES BETWEEN THE EQUAL SIGN. It must be as shown to work. Now you have named your item successfully!

Finishing Up Edit

Good job! You have successfully added your own item! If you need to review any of the material, click here to go to my github. If you have any problems or would like to talk to me, comment below! If you're all finished up, click here to go back home.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.