Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join server directly after launching the game #8

Closed
MkSui opened this issue Jun 18, 2022 · 7 comments
Closed

Join server directly after launching the game #8

MkSui opened this issue Jun 18, 2022 · 7 comments

Comments

@MkSui
Copy link

MkSui commented Jun 18, 2022

i want to join server automatically
but
launch 1.19 -commands "--server 1.1.1.1"
launch 1.19 -commands "--server" "1.1.1.1"
launch 1.19 -commands "server 1.1.1.1"
Not working at all

@3arthqu4ke
Copy link
Owner

Sorry but that's not possible and I'm not sure where you got the idea from that it is. In order to support this I would have to write specific code for every single Minecraft version.

You could however install fabric/forge for 1.19 and use the HMC-Specifics. Then, after launching the game, you can execute the following commands:

  • gui (dumps the gui in text form, will probably look like this:
Screen: net.minecraft.client.gui.screens.TitleScreen
Buttons:
0    Multiplayer                               113   132   200   20   1    Button
1    Singleplayer                              113   108   200   20   1    Button
2    Minecraft Realms                          215   156   98    20   1    Button
3    Mods                                      113   156   98    20   1    Button
4    Language                                  89    192   20    20   1    ImageButton
5    Options...                                113   192   98    20   1    Button
6    Quit Game                                 215   192   98    20   1    Button
7    Accessibility                             317   192   20    20   1    ImageButton
8    Copyright Mojang AB. Do not distribute!   229   230   196   10   1    PlainTextButton
TextFields:
id   text   x   y   w   h   type
-    -      -   -   -   -   -
  • click 0 (clicks the Multiplayer button)
  • gui (again, dump the Multiplayer gui)
  • If it's you first time launching the game Minecraft might display the "Caution Third party, .." screen. In order to skip use
    click 2 to check the "Don't show again" checkbox, then click 1 to proceed.
  • gui (always do gui after you clicked something)
  • You should be on the Multiplayer screen, click 0 for "Direct Connection"
  • gui (you get the idea)
  • text 2 <ip of the server>
  • gui (of course)
  • click 1 on older versions the "Join" button might disabled still, in that case add the -enable flag.
  • You should now be connecting to the server.

Another option would be to get 1.19 mappings and do it programmatically using the -commands flag and its reflection commands without the HMC-Specifics but that's even worse.

@MkSui
Copy link
Author

MkSui commented Jun 18, 2022

A custom minecraft launcher named HMCL could join server automatically(sad it didn't support command start), by add '--server' 'x.x.x.x' '--port' '25565' args or edit in config gui
https://sm.ms/image/iCQUq1KVpJHuSjN
This is the minecrft start script HMCL generated

Set-Location -Path 'C:\Users\mikus\AppData\Roaming\.minecraft'
& 'C:\Program Files\Microsoft\jdk-17.0.3.7-hotspot\bin\java.exe' '-Dfile.encoding=GB18030' '-Dminecraft.client.jar=C:\Users\mikus\AppData\Roaming\.minecraft\versions\1.19\1.19.jar' '-XX:+UnlockExperimentalVMOptions' '-XX:+UseG1GC' '-XX:G1NewSizePercent=20' '-XX:G1ReservePercent=20' '-XX:MaxGCPauseMillis=50' '-XX:G1HeapRegionSize=16m' '-XX:-UseAdaptiveSizePolicy' '-XX:-OmitStackTraceInFastThrow' '-XX:-DontCompileHugeMethods' '-Xmn128m' '-Xmx9551m' '-Dfml.ignoreInvalidMinecraftCertificates=true' '-Dfml.ignorePatchDiscrepancies=true' '-Djava.rmi.server.useCodebaseOnly=true' '-Dcom.sun.jndi.rmi.object.trustURLCodebase=false' '-Dcom.sun.jndi.cosnaming.object.trustURLCodebase=false' '-Dlog4j2.formatMsgNoLookups=true' '-Dlog4j.configurationFile=C:\Users\mikus\AppData\Roaming\.minecraft\versions\1.19\log4j2.xml' '-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump' '-Djava.library.path=C:\Users\mikus\AppData\Roaming\.minecraft\versions\1.19\natives-windows-x86_64' '-Dminecraft.launcher.brand=HMCL' '-Dminecraft.launcher.version=3.5.3' '-cp' 'C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\logging\1.0.0\logging-1.0.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\blocklist\1.0.10\blocklist-1.0.10.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\patchy\2.2.10\patchy-2.2.10.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\github\oshi\oshi-core\5.8.5\oshi-core-5.8.5.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\net\java\dev\jna\jna\5.10.0\jna-5.10.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\net\java\dev\jna\jna-platform\5.10.0\jna-platform-5.10.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\slf4j\slf4j-api\1.8.0-beta4\slf4j-api-1.8.0-beta4.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-slf4j18-impl\2.17.0\log4j-slf4j18-impl-2.17.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\ibm\icu\icu4j\70.1\icu4j-70.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\javabridge\1.2.24\javabridge-1.2.24.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\net\sf\jopt-simple\jopt-simple\5.0.4\jopt-simple-5.0.4.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-common\4.1.77.Final\netty-common-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-buffer\4.1.77.Final\netty-buffer-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-codec\4.1.77.Final\netty-codec-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-handler\4.1.77.Final\netty-handler-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-resolver\4.1.77.Final\netty-resolver-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-transport\4.1.77.Final\netty-transport-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-transport-native-unix-common\4.1.77.Final\netty-transport-native-unix-common-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\io\netty\netty-transport-classes-epoll\4.1.77.Final\netty-transport-classes-epoll-4.1.77.Final.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\google\guava\guava\31.0.1-jre\guava-31.0.1-jre.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\commons-io\commons-io\2.11.0\commons-io-2.11.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\brigadier\1.0.18\brigadier-1.0.18.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\datafixerupper\5.0.28\datafixerupper-5.0.28.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\google\code\gson\gson\2.8.9\gson-2.8.9.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\authlib\3.5.41\authlib-3.5.41.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\it\unimi\dsi\fastutil\8.5.6\fastutil-8.5.6.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-api\2.17.0\log4j-api-2.17.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\apache\logging\log4j\log4j-core\2.17.0\log4j-core-2.17.0.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\3.3.1\lwjgl-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\3.3.1\lwjgl-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl\3.3.1\lwjgl-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-jemalloc\3.3.1\lwjgl-jemalloc-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-jemalloc\3.3.1\lwjgl-jemalloc-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-jemalloc\3.3.1\lwjgl-jemalloc-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-openal\3.3.1\lwjgl-openal-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-openal\3.3.1\lwjgl-openal-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-openal\3.3.1\lwjgl-openal-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-opengl\3.3.1\lwjgl-opengl-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-opengl\3.3.1\lwjgl-opengl-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-opengl\3.3.1\lwjgl-opengl-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-glfw\3.3.1\lwjgl-glfw-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-glfw\3.3.1\lwjgl-glfw-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-glfw\3.3.1\lwjgl-glfw-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-stb\3.3.1\lwjgl-stb-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-stb\3.3.1\lwjgl-stb-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-stb\3.3.1\lwjgl-stb-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-tinyfd\3.3.1\lwjgl-tinyfd-3.3.1.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-tinyfd\3.3.1\lwjgl-tinyfd-3.3.1-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\org\lwjgl\lwjgl-tinyfd\3.3.1\lwjgl-tinyfd-3.3.1-natives-windows-x86.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\text2speech\1.13.9\text2speech-1.13.9.jar;C:\Users\mikus\AppData\Roaming\.minecraft\libraries\com\mojang\text2speech\1.13.9\text2speech-1.13.9-natives-windows.jar;C:\Users\mikus\AppData\Roaming\.minecraft\versions\1.19\1.19.jar' 'net.minecraft.client.main.Main' '--username' '' '--version' '1.19' '--gameDir' 'C:\Users\mikus\AppData\Roaming\.minecraft' '--assetsDir' 'C:\Users\mikus\AppData\Roaming\.minecraft\assets' '--assetIndex' '1.19' '--uuid' '' '--accessToken' '' '--clientId' '${clientid}' '--xuid' '${auth_xuid}' '--userType' 'mojang' '--versionType' 'HMCL 3.5.3' '--width' '854' '--height' '480' '--server' 'x.x.x.x' '--port' '25565'

Sorry for the length, I have no idea to cut short:(

@3arthqu4ke
Copy link
Owner

Ohhh, I didn't realize this was a Minecraft feature.
Add the following to your config.properties file:

hmc.gameargs=--server x.x.x.x --port 25565

@MkSui MkSui closed this as completed Jun 18, 2022
@3arthqu4ke 3arthqu4ke changed the title some stupid question Join server directly after launching the game Jun 18, 2022
@dolphin-cat
Copy link

i believe it is --server ip:port, not --server ip --port port

@3arthqu4ke
Copy link
Owner

Screenshot 2022-09-01 120836
Minecrafts code says no, its --server ip --port port.

@nothub
Copy link

nothub commented Apr 1, 2024

The behavior seems to vary depending on version.

Passing flags via hmc.gameargs works for me in 1.12.2 but stopped working in 1.20.4.

The 1.20.4 client just prints this line to logs on startup:
[main/INFO]: Completely ignored arguments: [--server, 172.17.0.1, --port, 25565]

@3arthqu4ke
Copy link
Owner

True, on 1.20.4 it seems to be a single argument: --quickPlayMultiplayer and then something like 127.0.0.1:25565.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants