Jump to content

[1.16] InputEvent.KeyInputEvent never fired


DARKHAWX

Recommended Posts

Hey there,

 

I'm trying to setup a basic keybinding, but I can't seem to get the event to fire. Here's my code for subscribing to the event:

 

@Mod.EventBusSubscriber
public class ModKeyInputs {

    @SubscribeEvent
    public void onKeyInput(InputEvent.KeyInputEvent event) {
        if (ModKeyBindings.OPEN_DIVINE_FAVOUR_RELATIONSHIP.isPressed()) {
            Minecraft.getInstance().displayGuiScreen(new DivineFavourRelationshipsScreen(Minecraft.getInstance().player));
        }
    }
}

 

Now I've put a breakpoint in the method there at the start, and I can never get it to fire. Am I subscribing to this event incorrectly?

 

As a side note, is there much difference between using @Mod.EventBusSubscriber on a class versus MOD_EVENT_BUS.register(ModKeyInputs.class); in the constructor of the main mod class?

No signature for you!

Link to comment
Share on other sites

10 minutes ago, DARKHAWX said:

As a side note, is there much difference between using @Mod.EventBusSubscriber on a class versus MOD_EVENT_BUS.register(ModKeyInputs.class); in the constructor of the main mod class?

They are basically the same. With the annotation method you can also specify the Dist where this event handler will be loaded on. What is wrong with your code is that your method is not declared as static. Take a look here for more info on events: https://mcforge.readthedocs.io/en/latest/events/intro/

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

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.