Posted November 25, 20159 yr Hi. Simple question I'm not sure about. MinecraftForge.EVENT_BUS.register(new EventHandler()); FMLCommonHandler.instance().bus().register(new EventHandler()); Would registering the same EventHandler on two buses (for different types of events) have any consequences? If so, could you explain why? Thanks. I try my best, so apologies if I said something obviously stupid!
November 25, 20159 yr I don't believe so, but I would only do that if you had several events in the same class that were on different buses. If the events aren't related, though, I would consider splitting them up into different classes. http://i.imgur.com/NdrFdld.png[/img]
November 25, 20159 yr Author Alright, thanks for clearing that up for me. Cheers! I try my best, so apologies if I said something obviously stupid!
November 25, 20159 yr Author Yes, I noticed I had used a new instance afterwards. Anyway I have removed the MinecraftForge.EVENT_BUS.register(new EventHandler()); line of code, so I guess it won't be a problem for the time being. Thank you for that, too. I try my best, so apologies if I said something obviously stupid!
November 26, 20159 yr Just as a note: Yes, in 1.8.8 this will have an impact. In 1.8.8 using this construct will make you receive all events twice, since the forge bus and the FML bus will be using the same object. FML does check for duplication like this, but it can only do so if you use the same instance, not a new one. I don't quite understand this. I thought the event handler method was called based on the method prototype. Doesn't the forge bus only look for methods that take event parameters for that bus, and similarly for the FML bus? Why would forge bus fire the LivingDropsEvent for example? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
November 26, 20159 yr Just as a note: Yes, in 1.8.8 this will have an impact. In 1.8.8 using this construct will make you receive all events twice, since the forge bus and the FML bus will be using the same object. FML does check for duplication like this, but it can only do so if you use the same instance, not a new one. I don't quite understand this. I thought the event handler method was called based on the method prototype. Doesn't the forge bus only look for methods that take event parameters for that bus, and similarly for the FML bus? Why would forge bus fire the LivingDropsEvent for example? The Forge and FML buses will be references to the same object (see how the FML bus is initialised here). If you register two instances of the same class on a bus, both instances will receive the event when it's fired. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
November 26, 20159 yr Aha, so we can declare a unique instance of a handler class and pass it to every bus that will accept it. The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
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.