pfgforge Posted November 8, 2016 Share Posted November 8, 2016 I'm looking for a way to call a function when an item is registered to the oredictionary so that I can automatically make simple dusts for my mod. Is there any way to do this, or should it be done differently? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 I dont think this is possible because items must be registered in there event which is called prior to preInit. Or it is done during preInit...And typically ore dictionary is done in init or postInit from my experience with it. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Draco18s Posted November 8, 2016 Share Posted November 8, 2016 OreRegisterEvent Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 OreRegisterEvent I saw this, but I'm not sure how to use it Quote Link to comment Share on other sites More sharing options...
Draco18s Posted November 8, 2016 Share Posted November 8, 2016 Subscribe to it, do whatever you want to. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 Subscribe to it, do whatever you want to. I've been looking for a while, but I don't know how to subscribe to events Quote Link to comment Share on other sites More sharing options...
Draco18s Posted November 8, 2016 Share Posted November 8, 2016 https://mcforge.readthedocs.io/en/latest/events/intro/ Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 https://mcforge.readthedocs.io/en/latest/events/intro/ Still not fully sure how to handle the event. I @SubscribeEvent, but what's it called and what are it's arguments? @SubscribeEvent public void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { Quote Link to comment Share on other sites More sharing options...
Draco18s Posted November 8, 2016 Share Posted November 8, 2016 public void OreRegisterEvent(OreRegisterEvent e) { } Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 public void OreRegisterEvent(OreRegisterEvent e) { } OreRegisterEvent cannot be resolved to a type Quote Link to comment Share on other sites More sharing options...
Draco18s Posted November 8, 2016 Share Posted November 8, 2016 Oh sorry, you were right the first time. I didn't realize the event was declared as a static class inside the OreDict. What's your problem? Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 Oh sorry, you were right the first time. I didn't realize the event was declared as a static class inside the OreDict. What's your problem? It never seems to get called Main mod file: @EventHandler public void preInit(FMLPreInitializationEvent event){ System.out.println("Preinit Was Called"); // Prints MinecraftForge.EVENT_BUS.register(new OreRegisterEventHandler()); } OreRegisterEventHandler: public class OreRegisterEventhandler { @SubscribeEvent public void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("An ore is being registered "+name); // Never prints } } Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 The @SubscribeEvent goes over the method not the class. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 The @SubscribeEvent goes over the method not the class. Sorry, pasted the code wrong. The subscribe event is over the method Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 The @SubscribeEvent goes over the method not the class. Sorry, pasted the code wrong. The subscribe event is over the method Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 The @SubscribeEvent goes over the method not the class. Sorry, pasted the code wrong. The subscribe event is over the method Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event? I went back to my post to edit it and add the class part, but accidentally put the subscribe event before the class. My actual code never had that. I am trying to register something into the oredict when the event is called (it won't loop infinitely, I have it set up right), but the event doesn't get called yet Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 The @SubscribeEvent goes over the method not the class. Sorry, pasted the code wrong. The subscribe event is over the method Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event? I went back to my post to edit it and add the class part, but accidentally put the subscribe event before the class. My actual code never had that. I am trying to register something into the oredict when the event is called (it won't loop infinitely, I have it set up right), but the event doesn't get called yet The event is fired when something is registered to the OreDictionary it is not used to register something to the OreDictionary specifically. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 The @SubscribeEvent goes over the method not the class. Sorry, pasted the code wrong. The subscribe event is over the method Did you re paste the code or just fix that one error? And also are you registering something into the ore dictionary after registering the event? I went back to my post to edit it and add the class part, but accidentally put the subscribe event before the class. My actual code never had that. I am trying to register something into the oredict when the event is called (it won't loop infinitely, I have it set up right), but the event doesn't get called yet The event is fired when something is registered to the OreDictionary it is not used to register something to the OreDictionary specifically. I know. Forge by default registers some ores, and when they are registered I want this method to be called so I can register my own based on them. Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 Then instead of registering the event in preInit use the static way of registering it was in the link Dracos provided. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 Then instead of registering the event in preInit use the static way of registering it was in the link Dracos provided. I switched it to a static void, but it still doesn't work @EventHandler public void preInit(FMLPreInitializationEvent event){ System.out.println("This is printed, showing that the preinit is running"); MinecraftForge.EVENT_BUS.register(OreRegisterEventhandler.class); public class OreRegisterEventhandler { @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This never gets called, and is never printed. It should get called because forge registers some ores by default"+name); Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 I meant this part Automatically Registering Static Event Handlers Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 I meant this part Automatically Registering Static Event Handlers Tried in both OreRegisterEventhandler and in the main mod file. @Mod.EventBusSubscriber public class OreRegisterEventhandler { @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This doesn't get printed ever "+name); @Mod(modid = modname.MODID, version = modname.VERSION) @Mod.EventBusSubscriber public class modname { // init functions and stuff... @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This also doesn't get printed "+name); Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 I meant this part Automatically Registering Static Event Handlers Tried in both OreRegisterEventhandler and in the main mod file. @Mod.EventBusSubscriber public class OreRegisterEventhandler { @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This doesn't get printed ever "+name); @Mod(modid = modname.MODID, version = modname.VERSION) @Mod.EventBusSubscriber public class modname { // init functions and stuff... @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This also doesn't get printed "+name); The problem now that I am looking at this class is that the method that registers vanilla is called as soon as a static{} gets called. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
pfgforge Posted November 8, 2016 Author Share Posted November 8, 2016 I meant this part Automatically Registering Static Event Handlers Tried in both OreRegisterEventhandler and in the main mod file. @Mod.EventBusSubscriber public class OreRegisterEventhandler { @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This doesn't get printed ever "+name); @Mod(modid = modname.MODID, version = modname.VERSION) @Mod.EventBusSubscriber public class modname { // init functions and stuff... @SubscribeEvent public static void OreRegisterEvent(OreDictionary.OreRegisterEvent e) { String name = e.getName(); System.out.println("This also doesn't get printed "+name); The problem now that I am looking at this class is that the method that registers vanilla is called as soon as a static{} gets called. So... should I loop over all the oredict entries postinit? Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted November 8, 2016 Share Posted November 8, 2016 Depends on what you mean post update? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Recommended Posts
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.