Jump to content

[1.19.3] Why doesn't my keybind work?


Recommended Posts

public class ClientEvents {
    @Mod.EventBusSubscriber(modid = Mymod.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.FORGE)
    public static class ClientForgeEvents{
        @SubscribeEvent
        // Event is on the Forge event bus only on the physical client
        public void onClientTick(TickEvent.ClientTickEvent event) {
            if (event.phase == TickEvent.Phase.END) { // Only call code once as the tick event is called twice every tick
                while (KeyBinding.SET_ITEM_KEY.consumeClick()) {
                    // Execute logic to perform on click here
                    Minecraft.getInstance().player.sendSystemMessage(Component.literal("Key is pressed!"));
                }
            }
        }
    }

    @Mod.EventBusSubscriber(modid = Mymod.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
    public static class ClientModEvents{
        @SubscribeEvent
        public static void onKeyRegister(RegisterKeyMappingsEvent event){
            event.register(KeyBinding.SET_ITEM_KEY);
        }

        @SubscribeEvent
        public void gatherData(GatherDataEvent event) {

        }
    }
}

Nothing appends when I press the key I set.

I followed the forge docs. Did I make mistakes? Help needed. THANK YOU!

Link to comment
Share on other sites

Quote

public static class ClientForgeEvents{

@SubscribeEvent

// Event is on the Forge event bus only on the physical client

- public void onClientTick(TickEvent.ClientTickEvent event) {

+ public static void onClientTick(TickEvent.ClientTickEvent event) {

 

https://forge.gemwire.uk/wiki/Events#/media/File:Guide_to_Event_Handlers.png

  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

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