maruohon / malilib

Library mod for masa's client-side Minecraft mods
GNU Lesser General Public License v3.0
294 stars 124 forks source link

`StringUtils.getWorldOrServerName` returns `null` if Minecraft is started with `--server` option (autoconnect) #107

Open globau opened 1 year ago

globau commented 1 year ago

If Minecraft is started with the -server option to automatically connect to a multiplayer server on launch, sadly MinecraftClient's getCurrentServerData/getCurrentServerEntry method returns null, which is then the result of StringUtils.getWorldOrServerName.

This results in some weirdness in Litematica - eg. placements are never saved.

One workaround is to inject MinecraftClient's constructor to grab the command line args, falling back to args.autoConnect.serverAddress if MinecraftClient.getCurrentServerEntry() returns null.

globau commented 1 year ago

Looks like 1.20 no longer accepts the -server option.

(edit)

23w14a replaced -server with --quickPlaySingleplayer, --quickPlayMultiplayer, and --quickPlayRealms