Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Forge 1.14.4] Unwanted Closed Channel


geekles
 Share

Recommended Posts

I am currently developing a mod that is an updated version of mods such as "Hardcore Darkness". Being this is my first "real" mod,  I was glad to see that I was able to successfully instantiate a new channel for both the server and client to use. This would essentially allow the server to ensure the player has the mod installed before letting them in, which is exactly what I wanted. However, I also want to give the player the option to join a server if they have the mod installed on their client even if the server isn't forge or has the mod installed on the server. However, because of the "forge handshake", it will automatically close the connection from the client to the server if the server doesn't have a channel for it to communicate with my mod with. I want it so that I can disable the client from closing the connection if there is no open channel to communicate with the mod. Not sure how to do this. The mod (at the moment), has no real need to send custom packets to the server since the mechanics simply mess with the visuals (darkness, fog levels, etc.) Therefore there is no need for there to be any information to be synced across all the clients across the server, asides for weather and time which is already sent by the server by default. So far, I know the following lines in the FMLHandshakeHandler is the culprit for the issue:

    void handleServerModListOnClient(FMLHandshakeMessages.S2CModList serverModList, Supplier<NetworkEvent.Context> c)
    {
        LOGGER.debug(FMLHSMARKER, "Logging into server with mod list [{}]", String.join(", ", serverModList.getModList()));
        boolean accepted = NetworkRegistry.validateClientChannels(serverModList.getChannels());
        c.get().setPacketHandled(true);
        if (!accepted) {
            LOGGER.error(FMLHSMARKER, "Terminating connection with server, mismatched mod list");
            c.get().getNetworkManager().closeChannel(new StringTextComponent("Connection closed - mismatched mod channel list"));
            return;
        }
      [...]

I've tried going through the classes to see how it gets from point A (see below) to point B (see above). Too many variables and functions are being called however and it isn't clear how or from what that function gets called. 

            INSTANCE = NetworkRegistry.newSimpleChannel(
                    new ResourceLocation(Blackout.ID, "main"),
                    () -> PROTOCOL_VERSION,
                    PROTOCOL_VERSION::equals,
                    PROTOCOL_VERSION::equals
            );

 

Edited by geekles
Link to comment
Share on other sites

When registering your channel you provide two predicates (Predicate<String>) to test on server and client whether the remote version should be accepted. If the mod is not installed on the other side, NetworkRegistry.ABSENT will be passed as the version. If your predicate returns true, the connection is allowed.

Link to comment
Share on other sites

 
 
 
1
6 hours ago, diesieben07 said:

When registering your channel you provide two predicates (Predicate<String>) to test on server and client whether the remote version should be accepted. If the mod is not installed on the other side, NetworkRegistry.ABSENTwill be passed as the version. If your predicate returns true, the connection is allowed.

How would I listen for when this NetworkRegistry.ABSENT  is passed? I assume perhaps there's an event I can cancel and handle it myself instead of having the client by default close the connection. 

Edited by geekles
Link to comment
Share on other sites

10 hours ago, geekles said:

PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals

These two are the predicates I talked about. You need to pass an implementation here (a lambda expression would be easiest) that also handles ABSENT instead of only allowing an exact match of PROTOCOL_VERSION.

Link to comment
Share on other sites

23 minutes ago, diesieben07 said:

These two are the predicates I talked about. You need to pass an implementation here (a lambda expression would be easiest) that also handles ABSENT instead of only allowing an exact match of PROTOCOL_VERSION.

Which one though. Should both handle an unmatched Protocol_Version?

Link to comment
Share on other sites

clientAcceptedVersions: Controls which server versions the client will accept. If you make this accept ABSENT it means that a client with your mod can connect to a server without your mod.

serverAcceptedVersions: Controls which client versions the server will accept. If you make this accept ABSENT it means that a client wihtout your mod can connect to a server with your mod.

Link to comment
Share on other sites

9 minutes ago, diesieben07 said:

clientAcceptedVersions: Controls which server versions the client will accept. If you make this accept ABSENT it means that a client with your mod can connect to a server without your mod.

serverAcceptedVersions: Controls which client versions the server will accept. If you make this accept ABSENT it means that a client wihtout your mod can connect to a server with your mod.

Thank you. I'll give it a try soon. 

Edited by geekles
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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Mr. diesieben07 und Mr. Luis_ST. Ich danke Ihnen für Ihre Geduld. Erst jetzt habe ich gelernt, dass "Listen Events" als Parameter zurückgegeben werden, also habe ich auch gelernt, dass man Methoden direkt mit Parametern aufrufen kann. Ich stelle den Ereigniscode zur Verfügung, weil es sich um ein geringfügiges Problem handelt und ich ein sehr schlechter Fragesteller wäre, wenn Sie auch für dieses Problem den Ereigniscode selbst durchgehen müssten. Ich verwende derzeit ein Übersetzungsgerät, um mit Ihnen zu kommunizieren, daher werden viele Wörter nicht klar und deutlich zu verstehen sein, und ich entschuldige mich für etwaige Missverständnisse. Ich bin Ihnen beiden dankbar, dass Sie sich trotz Ihres vollen Terminkalenders die Zeit genommen haben, um meine Fragen zu beantworten. Ich gebe Ihnen beiden ein Dankeschön, um meine Dankbarkeit auszudrücken. Ich danke Ihnen nochmals. :):)
    • Whenever I try to start my server I get this crash: [14:05:21] [main/FATAL]: Failed to start the minecraft server com.google.gson.JsonParseException: Error loading registry data: Not a valid resource location: #minecraft:infiniburn_end Non [a-z0-9_.-] character in namespace of location: #minecraft:infiniburn_end         at net.minecraft.core.RegistryAccess.m_175498_(RegistryAccess.java:156) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at java.util.Optional.ifPresent(Optional.java:178) ~[?:?]         at net.minecraft.core.RegistryAccess.m_175503_(RegistryAccess.java:155) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.core.RegistryAccess.m_175500_(RegistryAccess.java:146) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.resources.RegistryReadOps.m_195841_(RegistryReadOps.java:37) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.resources.RegistryReadOps.m_179866_(RegistryReadOps.java:31) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at net.minecraft.server.Main.main(Main.java:161) ~[server-1.18.1-20211210.034407-srg.jar%2390!/:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]         at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]         at net.minecraftforge.fml.loading.targets.CommonServerLaunchHandler.lambda$launchService$0(CommonServerLaunchHandler.java:46) ~[fmlloader-1.18.1-39.0.75.jar%2361!/:?]         at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) ~[modlauncher-9.1.0.jar%2343!/:?]         at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) ~[bootstraplauncher-1.0.0.jar:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]         at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]         at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]         at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]         at org.jmt.mcmt.modlauncher.FastUtilTransformerService.argumentValues(FastUtilTransformerService.java:200) ~[jmt_mcmt-1.18.1-0.24.2-118-packaged.jar%2375!/:?]         at cpw.mods.modlauncher.TransformationServicesHandler.lambda$offerArgumentResultsToServices$5(TransformationServicesHandler.java:80) ~[modlauncher-9.1.0.jar%235!/:?]         at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]         at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]         at java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) ~[?:?]         at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]         at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]         at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]         at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]         at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]         at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]         at cpw.mods.modlauncher.TransformationServicesHandler.offerArgumentResultsToServices(TransformationServicesHandler.java:80) ~[modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.ArgumentHandler.processArguments(ArgumentHandler.java:71) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.TransformationServicesHandler.processArguments(TransformationServicesHandler.java:68) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.TransformationServicesHandler.initializeTransformationServices(TransformationServicesHandler.java:50) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.Launcher.run(Launcher.java:87) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.0.jar%235!/:?]         at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?] container@pterodactyl~ Server marked as offline... [Game2 Daemon]: ---------- Detected server process in a crashed state! ---------- [Game2 Daemon]: Exit code: 1 [Game2 Daemon]: Out of memory: false [Game2 Daemon]: Aborting automatic restart, last crash occurred less than 120 seconds ago.
    • why, you have Event instance so call the getters we all have the code of the Event the Event exist to perform an action at a specific 'time'/'action' in the game what are you talking about
    • I am sorry, but I have zero idea what you are trying to say.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.