Jump to content

Recommended Posts

Posted

Hi! I created my first Forge mod, but it doesn't seem to be working. I don't really know what I was supposed to do, honestly this seems a bit easy, that's why I think I'm doing something completely wrong. So there's this ExampleMod.java file, which I edited, and first added a ClientChatEvent to detect a message and cancel it, also write something to the player, and then that didn't work so I tried ServerChatEvent, still doesn't work.
These are the first 4 lines of the code:

@EventHandler
    public void onChat(ServerChatEvent e) {
        mc.player.sendMessage(new TextComponentString("Hello there!"));
        System.out.println("MSG DETECTED");

It just doesn't do anything. Help is appreciated !

Posted
7 minutes ago, diesieben07 said:
    public class MyForgeEventHandler {
        @SubscribeEvent
        public void onChat(ServerChatEvent e) {
            mc.player.sendMessage(new TextComponentString("Hello there!"));
            System.out.println("MSG DETECTED");
            if (e.getMessage().equals(".help")) {
                e.setCanceled(true);

                mc.player.sendMessage(new TextComponentString("Hello there!"));
            }
        }
    }

Still not working. What am I doing wrong?

Posted
10 minutes ago, diesieben07 said:

Show where you register your event handler.

You're not showing where the handler is registered, you're just showing the subscribed event.

Go back and read the doc page about registering the event handler again. :)

Posted
8 minutes ago, Ugdhar said:

You're not showing where the handler is registered, you're just showing the subscribed event.

Go back and read the doc page about registering the event handler again. :)

Oh thanks, I found it, and it's working now! ?

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.