Posted April 10, 20178 yr I don't know if I should file a bug, but given that I'm new I'll try to ask first if my methodology is just wrong. When I check the documentation at: https://mcforge.readthedocs.io/en/latest/concepts/registries/ It says at the moment of writing this to use events for registering items Quote The recommended way to register things is through the RegistryEvents. When I register my item through events, by subscribing to RegistryEvent.Register[Item] And adequately register the event, I get no items in the creative tab of my mod. However, when I use the ways I find in tutorials, by calling GameRegistry.register at preInit, I get my items in my mod creative tab. According to the documentation this is the old way while the recommended event way of registering happens before preInit. Is this intended? Or a bug? I tried calling both, but you can only register items once. If you do it both the game crashes specifically at preInit because the item was already registered in the event that happens before preInit. Edited April 10, 20178 yr by ctbe
April 10, 20178 yr It depends on where you initialize your creative tab. The RegisterEvents are called before preInit, so if you initialize your creative tab in preInit, you will set the Item's creative tab to null at the point when you register your Items. You should initialize it at the same time you declare the creative tab variable. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
April 10, 20178 yr Author Thanks. It was me then. Before, I was setting the creative tab for my item at the constructor of my item. But because you need the item to exist before registering it and the register event got launched before the creative tab for the mod was even created, what you said was happening. It was setting the item's creative tab to null at creation. I fixed it by creating a method in my item's class that sets the creative tab and manually calling said method at preInit, when I know for sure the creative tab for my mod will already exist. Edited April 10, 20178 yr by ctbe
April 11, 20178 yr 12 hours ago, ctbe said: I fixed it by creating a method in my item's class that sets the creative tab and manually calling said method at preInit, when I know for sure the creative tab for my mod will already exist. Why? There is already a method to set the creative tab, just call that in preInit
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.