Jump to content

[1.13.2] How to recieve Plugin Messages?


LK520

Recommended Posts

    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 by LK520
Link to comment
Share on other sites

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

 

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.