Jump to content

[1.16.1] Listening on an event which does not implement IModBusEvent


Recommended Posts

Posted

My mod has always had listeners on various events, one of which is RenderGameOverlayEvent.

Since 1.16.1 - 32.0.90 and the introduction of IModBusEvent, my mod fails to load because the listener for this event is not a subtype of IModBusEvent.

I can see this described in the Changelog as

Introduced IModBusEvent as a marker interface for events on the ModBus. Expect exceptions if you use
		the modbus for events not listened there.

However, I am unclear as to how I should fix the problem (...or even if I can fix it yet. Maybe I have to wait for further code changes in Forge?)

Any advice would be greatly appreciated. Thanks

Posted

Well, it's been registered the same way through all the prior versions and was working fine up until 32.0.88. Then this change was made and it no longer works, but I'd like some advice as to how to set a listener on the RenderGameOverlayEvent. Just saying I did it wrong is not very helpful to me.

Posted

I'm sure it must have been firing, or the information I'm displaying on screen would never have appeared. My code would never have been called.

So, could you tell me which event I should subscribe to and listen on if I want to display something on screen whenever the main game overlay is being rendered?

I would be grateful for any practical assistance.

Posted

RenderGameOverlayEvent does not fire on the Mod Bus, if you can provide code that proves otherwise then please do.

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted

I'm not trying to prove a point. Honestly. I just want to know what I should be doing.

My mod displays coordinates, a timer and some other information on screen. I've been maintaining a Forge version of it since Minecraft 1.0.1. I need an event that fires when the game screen is being rendered, to call my code to display this information.

Am I understanding correctly, that the only events that I can subscribe/listen to are those that implement IModBusEvent? Because there don't seem to be any of them that are connected with screen rendering.

It would be a sad day if I had to stop my mod at version 1.15.2, having maintained it for 7 years, but I can see that's where we're heading with this conversation.

Posted
  On 8/8/2020 at 1:30 PM, BatHeart said:

So, could you tell me which event I should subscribe to and listen on if I want to display something on screen whenever the main game overlay is being rendered?

Expand  

RenderGameOverlayEvent is correct. Just the bus is not. Register to MinecraftForge.EVENT_BUS

Posted

Thanks @CAS_ual_TY Much appreciated!

I think I am registering to MinecraftForge.EVENT_BUS. I think the problem may be with how I am adding my listeners.

For example:

final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

modEventBus.addListener(battyUI::renderPlayerInfo);

but when I register it:

MinecraftForge.EVENT_BUS.register(new BattyUI(Minecraft.getInstance()));

And in the BattyUI class:

@SubscribeEvent
public void renderPlayerInfo(RenderGameOverlayEvent event) {

 

I think the problem may be that I am getting the wrong type of mod event bus before I add the listener. As you can see, I am getting an IEventBus.

I think I need to find a way of getting an IModBusEvent.

Or am I still confused?

Posted

What you just gave me doesnt help me at all. I dont know what renderPlayerInfo does. I also dont know where you register all of this (when its fired).

So until you show more context Ill just give you some general stuff:

 

There is 2 different buses:

- mod bus, for "mod construction" events (eg. FMLCommonSetupEvent, TextureStichEvent, ModelRegistryEvent, ModConfigEvent etc.)

- forge bus, for general minecraft events (eg. RenderGameOverlay, EntityJoinedTheWorld...)

 

And there is different methods of registering. This sums it up:

unknown.png

Posted

Thanks everyone. I believe I understand it better now. My .addListener() calls were never doing anything. Everything was handled by the @SubscribeEvent and the MinecraftForge.EVENT_BUS.register() calls.

I have now taken out all of the .addListener() code, and Forge now loads my mod, and the mod still works.

Batty's Mod does not end with 1.15.2! This will be good news to my 'customers' who have been asking me why it suddenly stopped working 😄

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.