![]() In this text file add the following line: =YOUR NAMEĪnd again, replace the words in caps with your own values. modid package create a new package called lang, in this package create a new text file. That is because we haven’t added a lang file yet, so lets do that. You may have noticed that the name isn’t displaying correct. The texture name shouldn’t contain the extension (. You have to replace the words in capslock with the corresponding values. Save it under the same name as your item but make sure it is all lowercase or it won’t work, also remember to save it as NAME. In the text file add the following json code: In the em package create a new text file. I will call it tutorial_item.png and I will use this texture: It doesn’t matter what you call it but it has to be lowercase and you have to remember the name. In the ems package you can add a texture (make sure its size is a power of 2, 16×16, 32×32, etc.). Create: em and ems (make sure you don’t have a “s” behind item after models). In this package we have to create some more packages. modid and ofcourse replace modid with your modid. To add a model and texture create a new package in the src/main/resources folder called assets. Your item will now have a location registered, we haven’t added a model and texture yet so forge will change it with a custom model telling you the location. In the registerRenders method call the registerRender method and pass it your custom item. This line will set the location of the item model. Don’t forget to add an annotation above the method!Īdd another method, this method is also static and takes an Item as argument, I will call it registerRender (without an “s”!). In this method add the following line: tCustomModelResourceLocation(item, 0, new ModelResourceLocation( item.getRegistryName(), "inventory")) Add a public static method called registerRenders with as argument ModelRegistryEvent. In the ModItems class we will use another event to register the model location of the item. When you do this you will see that it doesn’t have a model and texture yet. When you start the game, and load a world you can give yourself the item with the command: “/give modid : itemname”. This is technically enough for forge to load the item. In the Main class’ init method call the init method of the ModItems class. In the registerItems method register your item by calling the register method like this: Above the method add an annotation and above the class declaration add an annotation add an modid attribute. ![]() Add a public static method called registerItems it has to have an argument of type RegistryEvent.Register. Now we need to let forge know we have an item to register, this is done in the RegistryEvent. In the init function initialize the tutorial_item variable. It will return nothing and it doesn’t need any arguments. This method will be called in the preInit function of our Main class and initialize all of our items. In the ModItems class create a static variable of type Item, I will call it tutorial_item and a public static method called init. In the ModItems class we will be instantiating and registring our objects. This class will be the most basic item possible, it won’t have any special effects. This name is used internally and should never be changed after assigning the item. The setRegistryName will set the registryName of the item. The setUnlocalizedName method will set the unlocalizedName of the item, this will add item. Inside of the constructor call the methods: “ setUnlocalizedName and setRegistryName” and pass them the name variable. Now add a constructor with a String name. The ItemBasic class should extend Item (When importing make sure to import “”). Your package structure should now look a little like this: Inside the init package create a class ModItems.Inside the items package create a class ItemBasic.In this package we will put all of our item, block etc. Create another package inside the mod package and call it init.This package will contain all of the custom item classes. Create a package in your mod package and call it items.First we are going to create some packages and files.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |