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.

packet listener for forge 1.8.9 doesn't work

Featured Replies

Posted

Greetings, I am currently trying to register a packet listener for forge 1.8.9 like this:
 

public class NameChangePacketListener {
    @SubscribeEvent
    @SideOnly(Side.CLIENT)
    public void onPacketReceived(FMLNetworkEvent.ClientCustomPacketEvent event) throws IOException {
        System.out.println("test");
        

        if (event.packet.toS3FPackets() instanceof S38PacketPlayerListItem) {
            S38PacketPlayerListItem packet = (S38PacketPlayerListItem) event.packet.toS3FPackets();

            if (packet.func_179768_b() == S38PacketPlayerListItem.Action.UPDATE_DISPLAY_NAME) {
                for (S38PacketPlayerListItem.AddPlayerData playerData : packet.func_179767_a()) {
                    String newName = playerData.getDisplayName().getUnformattedText();

                    IChatComponent chatComponent = new ChatComponentText("Your name has been changed")
                            .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN));
                    Minecraft.getMinecraft().thePlayer.addChatMessage(chatComponent);
                }
            }
        }
    }
}

Now, in the init method, I register this listener to the event bus like so:
 

@Mod.EventHandler
    @SideOnly(Side.CLIENT)
    public static void init(FMLInitializationEvent event){
        MinecraftForge.EVENT_BUS.register(new NameChangePacketListener());
    }


I know for a fact the init method works, so why does the "onPacketReceived" method not get called? the "test" doesn't print at all

1.8.9 is no longer supported as it is really really old https://forums.minecraftforge.net/topic/91712-supported-version-directory/

That being said, unfortunately I don't know how to help in this case, but since this version is unsupported I don't know if some will eventually come (hopefully it will, but it's unlikely)

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author

Thank you for your interest in helping me. Do you know another forum where I could post my problem at?

 

The only place I can think of is the Forge discord (or any other modding discord servers). But beside Forge and Kaupenjoe I don't know other Forge discord servers

Don't blame me if i always ask for your help. I just want to learn to be better :)

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.