Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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 !

  • Author
Just now, diesieben07 said:

Show where you register your event handler.

This could be the thing I'm missing.. How do I register it?

  • Author
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?

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. :)

  • Author
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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.