-
Posts
2 -
Joined
-
Last visited
Posts posted by graycatvr
-
-
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
packet listener for forge 1.8.9 doesn't work
in Modder Support
Posted
Thank you for your interest in helping me. Do you know another forum where I could post my problem at?