Posted April 29, 20205 yr 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 !
April 29, 20205 yr 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?
April 29, 20205 yr Author 7 minutes ago, diesieben07 said: https://mcforge.readthedocs.io/en/latest/events/intro/ 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?
April 29, 20205 yr 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.
April 29, 20205 yr 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.