Posted July 10, 20178 yr I am brand new to modding and I am having trouble understanding the Registry Events to add some items and blocks. I have crated my registerItems method and I am not sure what or how to call it during game Initialization. Initialization Class: @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = "1.12") public class ExampleMod { @Instance public static ExampleMod instance; @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY) public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { System.err.println("PreINIT started"); //Register Items //REgister Tile Entities //Register Entities //Assign Ore dictionary } @EventHandler public void init(FMLInitializationEvent event) { System.err.println("INIT started"); //Register World Gens //Register recipes //Register EventHandlers //Sending IMC Messages } @EventHandler public void postInit(FMLPostInitializationEvent event) { System.err.println("PostINIT started"); //Mod Compatibility } } RegistryEventHandler class: @Mod.EventBusSubscriber(modid = Reference.MODID) public class RegistryEventHandler { @SubscribeEvent public void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ModItems.ITEMS); for(Block block : ModBlocks.BLOCKS) { event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName())); } System.err.print("Registered Items"); } @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Block block: ModBlocks.BLOCKS) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } for (Item item: ModItems.ITEMS) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } } } My Mod Items class has the Item array for registration. Please help me understand how these work! Thanks in advance!
July 10, 20178 yr Your register items isn't static. also this will crash on a dedicated server as ModelRegistryEvent is only on the client Edited July 10, 20178 yr by CoderAtParadise Did you really need to know?
July 10, 20178 yr 5 minutes ago, CoderAtParadise said: Your register items isn't static. also this will crash on a dedicated server as ModelRegistryEvent is only on the client Does ModelRegistryEvent get called on the server? I would think it would never fire on the server so this code would be safe.
July 10, 20178 yr You can have ModelRegistryEvent handlers on the server side, because the ModelRegistryEvent class does exist on the server but won't be fired there and nothing else in the method signature uses client only classes, however, it's best practice to keep your client-side code entirely separated from common code so it's harder to accidentally introduce client sided-ness bugs. Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
July 10, 20178 yr Yeah couldn't remember completely if the event was on the server but generally what you do in the event is not Did you really need to know?
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.