Good evening!
As a result of this Thread on the forge support forums:
https://www.minecraftforge.net/forum/topic/70484-how-does-recieving-plugin-messages-in-1132-work/
If a plugin message is send in bukkit/spigot via
player.sendPluginMessage(pluginInstance, "namespace:path", message);
the resulting packet cannot be received on the forge client side. As I don't fully understand what the origin of this problem is, I am quoting "diesieben07" from the forge support forums:
However I just checked the Forge source code and it seem in 1.13.2 Forge no longer registers plugin channels on the minecraft:register and minecraft:unregister channels. This is a bug, you should report it as a Github issue.
The origin is, as I assume, that bukkit/spigot follows the original "specification" by Dinnerbone. This states:
and should make sure that no Plugin Messages are sent to any clients that haven't announced that they are listening for that specific channel.
So if Forge does not announce the mod channels, bukkit will simply drop the messages on those channels.
This is intended. This specification is useless in modded minecraft, adds a pointless additional network burden to save very very little. If there is impetus to update it to something more useful, I will happily sit down and talk with whomever wishes to speak.
Is there any other way to receive plugin messages from bukkit/spigot in forge? If not, it would be very useful to have it added in some way (one popular use case of this was for example in the worldedit cui mod). Sadly, my knowlege of the forge code base is way to little to do it myself
I am also struggling to receive messages - I believe we need to send a register packet to bukkit to subscribe to plugin messages?
After creating a channel called minecraft:register on forge client
public static SimpleChannel channelRegister = NetworkRegistry.ChannelBuilder
.named(new ResourceLocation("minecraft", "register"))
.clientAcceptedVersions(PROTOCOL_VERSION::equals)
.serverAcceptedVersions(PROTOCOL_VERSION::equals)
.networkProtocolVersion(() -> PROTOCOL_VERSION)
.simpleChannel();
I was able to hear other plugins on the register channel (orldedit:cui appears to be a message (i guess 'w' was read as the discriminator)
But sending a registration message back is where i am stuck
NB: I can confirm that Forge is able to hear messages as I can send a PacketPlayOutCustomPayload manually
OK. What is preventing bukkit/spigot from working? Forge doesn't care about registration. Send packets, it'll happily work. I would suggest talking to the bukkit/spigot people about this.
Craftbukkit/Spigot does not send messages addressed to channels that the client did not register for.
Spigot keeps a HashSet of all the channels a player is subscribed to in the CraftPlayer class. Channels are presumably added when the client announces it wants messages from a certain channel via minecraft:register. When a Bukkit plugin calls the Bukkit API method for sending a message, Spigot checks if the channel is in that set; if it's not, the message is not sent.
As Forge doesn't seem to announce via minecraft:register this makes it impossible to send the messages unless the plugin bypasses the API and hacks into Spigot to tell it the client is interested. (This destroys the plugin's compatibility)
FWIW Sponge checks whether the channel is registered. My justification is that it could save (potentially significant) bandwidth if a client doesn't listen to a channel.
Most helpful comment
FWIW Sponge checks whether the channel is registered. My justification is that it could save (potentially significant) bandwidth if a client doesn't listen to a channel.