Jump to content

packet listener for forge 1.8.9 doesn't work


graycatvr

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.