neoforged / NeoForge

Neo Modding API for Minecraft, based on Forge
https://projects.neoforged.net/neoforged/neoforge
Other
1.1k stars 161 forks source link

SimpleChannel.isRemoteConnected doesn't let you detect if a mod is actually installed on the other side. #289

Closed Speiger closed 3 months ago

Speiger commented 8 months ago

Minecraft Version: {Minecraft version} 1.18.2 or newer (don't have 1.17.2 instance but it isn't an issue in 1.16.4 which had this feature added)

NeoForge Version: Latest Commit at the time of writing

Basically the NetworkInstance is remote present function is described as: "You can test if your mod is installed on the client/server or if there is a channel that your mod uses is installed on the other side" Since 1.18.2 there was another line added that basically makes this function "not working" https://github.com/neoforged/NeoForge/blob/b33d8715a46d5977177d898f97b27423f5909aa8/src/main/java/net/neoforged/neoforge/network/NetworkInstance.java#L99

This line contains all mod channels that there are on the server if you are trying to test if a client has the channel present or not. Meaning this function could be also described as:

public boolean isRemotePresent(Connection manager) {
   return true;
}

This is an issue with forge and neofroge alike.

Now the question is. Is that intended or is that a bug. Personally i declare that as a bug.

embeddedt commented 3 months ago

The networking system was revamped in 1.20.4, and is now much more heavily based on using channels to detect the presence of mods, rather than sending the mod list. Therefore, I suspect this is not an issue anymore. Please open a new issue if the problem still exists with the new API.

Speiger commented 3 months ago

@embeddedt what would be the function to call to detect if a channel is present on the other side? (Assuming the channel is optional)

I developed for forge a simple "verification packet" that does everything so no matter the system it should work for any forge version but for future reference i would like to know this.

embeddedt commented 3 months ago

I think there is a hasChannel method on packet listeners now (at least in 1.20.5), but I haven't yet needed to work with the new networking system enough to be 100% sure (my mods typically don't use packets). If you can't find it, ask on Discord - someone should know the exact location.