Posted June 13, 20196 yr public ExampleMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); MinecraftForge.EVENT_BUS.register(this); EventNetworkChannel channel = NetworkRegistry.ChannelBuilder .named(new ResourceLocation("space", "a")) .clientAcceptedVersions(PROTOCOL_VERSION::equals) .serverAcceptedVersions(PROTOCOL_VERSION::equals) .networkProtocolVersion(() -> PROTOCOL_VERSION) .eventNetworkChannel(); channel.registerObject(this); channel.addListener(this::onClientPacket); } public void onClientPacket(NetworkEvent.ClientCustomPayloadEvent evt){ byte[] b = new byte[evt.getPayload().readableBytes()]; evt.getPayload().getBytes(0, b); System.out.println(b); //String s = new String(b,"utf-8"); } I tried to use this method to receive pluginmessage from the server, but it doesn't work Edited June 13, 20196 yr by LK520
June 13, 20196 yr Author This is what the console outputs: [20:07:10.225] [Netty Client IO #0/DEBUG] [ne.mi.fm.ne.FMLHandshakeHandler/FMLHANDSHAKE]: Starting new vanilla network connection. [20:07:10.491] [Netty Client IO #0/DEBUG] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Channel 'fml:loginwrapper' : Vanilla acceptance test: ACCEPTED [20:07:10.491] [Netty Client IO #0/DEBUG] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Channel 'fml:handshake' : Vanilla acceptance test: ACCEPTED [20:07:10.491] [Netty Client IO #0/DEBUG] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Channel 'fml:play' : Vanilla acceptance test: ACCEPTED [20:07:10.491] [Netty Client IO #0/DEBUG] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Channel 'space:a' : Vanilla acceptance test: REJECTED [20:07:10.492] [Netty Client IO #0/ERROR] [ne.mi.fm.ne.NetworkRegistry/NETREGISTRY]: Channels [space:a] rejected vanilla connections
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.