Jump to content

Recommended Posts

Posted
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!

Posted
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.

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.