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

Are we SSP, SMP Client or SMP server?


Xfel
 Share

Recommended Posts

I think it would be useful to add functions like isMultiplayerClient() and isMultiplayerServer() for use in shared code. the second one returns true if running on the server. the first one returns true if we are client and connected to a server. I could code this myself, but I think it would be good if this would be available at some central place.

Link to comment
Share on other sites

There is no generic way to obtain the world. In the client, you get it through ModLoader.getMinecraftInstance.theWorld, on the server, you have to deal with dimensions & co. I always need to write two implementations.

Link to comment
Share on other sites

If !MinecraftForge.isClient() then we are server and world is local
If MinecraftForge.isClient then
   if ModLoader.minecraft.world.isRemote then
      we are client and in SMP
   else
      we are client and ssp

I dont see what is hard?

 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Unfortunately, the given code won't compile on the server, as there is no ModLoader.getMinecraftInstance there. It may be possible to compile it on the client and then put it into the server file, but even if that would work, it would be absolutely bad coding style.

Link to comment
Share on other sites

Essentially what you're wanting is forge to have that crappy code, instead of your code.

And yes, it would work fine if you did it correcly.

HOWEVER, if you can write clean version of those then go for it.

Honestly, that isnt really needed, as simply knowing if you're the client or the server is enough.

Anything that interactes with the world, should have a reference to the world.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Patreon: http://www.patreon.com/lexmanos
Paypal: http://paypal.me/LexManos

BitCoin: 1Q8rWvUNMM2T1ZfDaFeeYQyVXtYoeT6tTn

Link to comment
Share on other sites

Unfortunately, the given code won't compile on the server, as there is no ModLoader.getMinecraftInstance there. It may be possible to compile it on the client and then put it into the server file, but even if that would work, it would be absolutely bad coding style.

 

You do realize that the second if statement shouldn't even be in the server code right?

Link to comment
Share on other sites

Honestly, that isnt really needed, as simply knowing if you're the client or the server is enough.

Anything that interactes with the world, should have a reference to the world.

 

Many operations only get an IBlockAccess instead of a world. Of course, I could cast it to World, but that's not a clean solution. And in some of these it is essentially important whether the world is remote or not, as many operations should only be done on the server in SMP.

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.

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

    • 2021-10-28 15:22:50,623 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2021-10-28 15:22:50,624 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [15:22:50] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [15:22:50] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [15:22:50] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [15:22:50] [main/INFO] [FML]: Forge Mod Loader version 11.15.1.2318 for Minecraft 1.8.9 loading [15:22:50] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_51, running on Windows 10:amd64:10.0, installed at C:\Users\silic\AppData\Roaming\.tlauncher\mojang_jre\jre-legacy\windows-x64\jre-legacy [15:22:50] [main/FATAL] [FML]: There appear to be jars extracted into the mods directory. This is VERY BAD and will almost NEVER WORK WELL [15:22:50] [main/FATAL] [FML]: You should place original jars only in the mods directory. NEVER extract them to the mods directory. [15:22:50] [main/FATAL] [FML]: The directories below appear to be extracted jar files. Fix this before you continue. [15:22:50] [main/FATAL] [FML]: Directory 1.17 contains [MANIFEST.MF] 2021-10-28 15:22:50,748 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2021-10-28 15:22:50,759 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2021-10-28 15:22:50,759 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [15:22:50] [main/ERROR] : Could not save crash report to C:\Users\silic\AppData\Roaming\.minecraft\crash-reports\fml-crash-2021-10-28_15:22:50.txt java.io.FileNotFoundException: C:\Users\silic\AppData\Roaming\.minecraft\crash-reports\fml-crash-2021-10-28_15:22:50.txt (The filename, directory name, or volume label syntax is incorrect)     at java.io.FileOutputStream.open0(Native Method) ~[?:1.8.0_51]     at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[?:1.8.0_51]     at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[?:1.8.0_51]     at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[?:1.8.0_51]     at java.io.FileWriter.<init>(FileWriter.java:90) ~[?:1.8.0_51]     at b.a(SourceFile:227) [b.class:?]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51]     at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51]     at net.minecraftforge.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:305) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:246) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:95) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupClient(FMLLaunchHandler.java:72) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.configureForClientLaunch(FMLLaunchHandler.java:34) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.common.launcher.FMLTweaker.injectIntoClassLoader(FMLTweaker.java:119) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [launchwrapper-1.12.jar:?]     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] [15:22:50] [main/INFO] [STDOUT]: [net.minecraftforge.fml.relauncher.CoreModManager:discoverCoreMods:306]: #@!@# FML has crashed the game deliberately. Crash report saved to: #@!@# C:\Users\silic\AppData\Roaming\.minecraft\crash-reports\fml-crash-2021-10-28_15:22:50.txt [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]: java.lang.RuntimeException: Extracted mod jars found, loading will NOT continue [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraftforge.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:298) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraftforge.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:246) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:95) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupClient(FMLLaunchHandler.java:72) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.configureForClientLaunch(FMLLaunchHandler.java:34) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraftforge.fml.common.launcher.FMLTweaker.injectIntoClassLoader(FMLTweaker.java:119) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [15:22:50] [main/INFO] [STDERR]: [net.minecraftforge.fml.relauncher.FMLLaunchHandler:setupHome:99]:     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [15:22:50] [main/ERROR] [FML]: An error occurred trying to configure the minecraft home at C:\Users\silic\AppData\Roaming\.minecraft for Forge Mod Loader java.lang.RuntimeException: Extracted mod jars found, loading will NOT continue     at net.minecraftforge.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:298) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:246) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:95) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupClient(FMLLaunchHandler.java:72) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.configureForClientLaunch(FMLLaunchHandler.java:34) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.common.launcher.FMLTweaker.injectIntoClassLoader(FMLTweaker.java:119) [forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [launchwrapper-1.12.jar:?]     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] [15:22:50] [main/ERROR] [LaunchWrapper]: Unable to launch java.lang.RuntimeException: Extracted mod jars found, loading will NOT continue     at net.minecraftforge.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:298) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.CoreModManager.handleLaunch(CoreModManager.java:246) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupHome(FMLLaunchHandler.java:95) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.setupClient(FMLLaunchHandler.java:72) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.relauncher.FMLLaunchHandler.configureForClientLaunch(FMLLaunchHandler.java:34) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraftforge.fml.common.launcher.FMLTweaker.injectIntoClassLoader(FMLTweaker.java:119) ~[forge-1.8.9-11.15.1.2318-1.8.9.jar:?]     at net.minecraft.launchwrapper.Launch.launch(Launch.java:115) [launchwrapper-1.12.jar:?]     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] Exception in thread "main" [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraftforge.fml.relauncher.FMLSecurityManager.checkPermission(FMLSecurityManager.java:30) [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.lang.SecurityManager.checkExit(SecurityManager.java:761) [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.lang.Runtime.exit(Runtime.java:107) [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]:     at java.lang.System.exit(System.java:971) [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraft.launchwrapper.Launch.launch(Launch.java:138) [15:22:50] [main/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]:     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)  
    • These libraries failed to download. try again.   commons-io:commons-io:2.4  
    • The server just crashed after loading terrain and i have no idea why it is happening Hope someone could help me out  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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