我正在尝试制作一个简单的定制Minecraft发射器的东西。
根据the Minecraft Wiki page for the Launcher, 应该可以使用命令行中的用户名和密码前缀运行Minecraft启动器,直接进入游戏,而不是通过启动器。
我尝试了各种版本的java -cp -u=username -p=password minecraft.jar net.minecraft.LauncherFrame
,它说的是旧方法:
java -cp minecraft.jar net.minecraft.LauncherFrame <username> <password>
旧方法打开了我的世界发射器,就好像我双击了jar文件一样,但它没有直接进入菜单屏幕。
新方法(使用密码和用户名作为前缀),给我一条错误消息,说明prefix -u=username or -p=password don't exist
。
对此有何帮助?我真的被卡住了。
答案 0 :(得分:17)
你可以这样做,你只需绕过发射器。
在%appdata%\.minecraft\bin
(或unixy系统上的~/.minecraft/bin
)中,有一个minecraft.jar文件。这是实际游戏 - 发射器运行它。
像这样调用它:
java -Xms512m -Xmx1g -Djava.library.path=natives/ -cp "minecraft.jar;lwjgl.jar;lwjgl_util.jar" net.minecraft.client.Minecraft <username> <sessionID>
将工作目录设置为.minecraft/bin
。
要获取会话ID,请发送POST(请求此页面):
https://login.minecraft.net?user=<username>&password=<password>&version=13
你会收到这样的回复:
1343825972000:deprecated:SirCmpwn:7ae9007b9909de05ea58e94199a33b30c310c69c:dba0c48e1c584963b9e93a038a66bb98
第四个字段是会话ID。 More details here。 阅读这些详细信息,此答案已过时
Here's an example使用C#登录minecraft.net,example of launching minecraft.jar。
答案 1 :(得分:3)
这个答案将简要解释如何在最新的启动器上处理本机文件。
截至4/29/2017,用于Windows的Minecraft启动程序将提取所有本机文件,并将它们放置在信息%APPDATA%\ Local \ Temp {random folder}中。该文件夹是临时文件夹,一旦javaw.exe进程完成(当Minecraft关闭时)就会被删除。必须在启动参数中提供该临时文件夹的位置作为
的值-Djava.library.path=
此外,最新的启动程序(2.0.847)没有显示启动参数,因此如果您需要自己检查它们,您可以在任务管理器下执行此操作(只需启用“命令行”选项卡并展开它)或使用WMIC
实用程序as explained here。
希望这有助于一些仍然对2017年这样做感兴趣的人。
答案 2 :(得分:3)
对于任何想为不同的 Minecraft 版本更可靠地执行此操作的人,我有一个 Python 脚本(改编自 minecraft-launcher-lib 的部分内容)可以很好地完成这项工作
除了在函数的顶部附近设置一些基本变量之外,它还调用一个get_classpath
函数,读取例如~/.minecraft/versions/1.16.5/1.16.5.json
,并循环遍历属性libraries
数组,检查是否每个对象(在数组内)都应该添加到类路径(cp
变量)中。是否将此库添加到 java 类路径由 should_use_library
函数控制,基于计算机的体系结构和操作系统确定。最后,一些特定于平台的 jarfile 有额外的内容(例如 natives-linux
中的 org/lwjgl/lwjgl/3.2.1/lwjgl-3.2.1-natives-linux.jar
)。这个额外的前置字符串由 get_natives_string
处理,如果它不适用于当前库,则为空
在 Linux 上测试,分发 Arch Linux
#!/usr/bin/env python3
import json
import os
import platform
from pathlib import Path
import subprocess
"""
Debug output
"""
def debug(str):
if os.getenv('DEBUG') != None:
print(str)
"""
[Gets the natives_string toprepend to the jar if it exists. If there is nothing native specific, returns and empty string]
"""
def get_natives_string(lib):
arch = ""
if platform.architecture()[0] == "64bit":
arch = "64"
elif platform.architecture()[0] == "32bit":
arch = "32"
else:
raise Exception("Architecture not supported")
nativesFile=""
if not "natives" in lib:
return nativesFile
if "windows" in lib["natives"] and platform.system() == 'Windows':
nativesFile = lib["natives"]["windows"].replace("${arch}", arch)
elif "osx" in lib["natives"] and platform.system() == 'Darwin':
nativesFile = lib["natives"]["osx"].replace("${arch}", arch)
elif "linux" in lib["natives"] and platform.system() == "Linux":
nativesFile = lib["natives"]["linux"].replace("${arch}", arch)
else:
raise Exception("Platform not supported")
return nativesFile
"""
[Parses "rule" subpropery of library object, testing to see if should be included]
"""
def should_use_library(lib):
def rule_says_yes(rule):
useLib = None
if rule["action"] == "allow":
useLib = False
elif rule["action"] == "disallow":
useLib = True
if "os" in rule:
for key, value in rule["os"].items():
os = platform.system()
if key == "name":
if value == "windows" and os != 'Windows':
return useLib
elif value == "osx" and os != 'Darwin':
return useLib
elif value == "linux" and os != 'Linux':
return useLib
elif key == "arch":
if value == "x86" and platform.architecture()[0] != "32bit":
return useLib
return not useLib
if not "rules" in lib:
return True
shouldUseLibrary = False
for i in lib["rules"]:
if rule_says_yes(i):
return True
return shouldUseLibrary
"""
[Get string of all libraries to add to java classpath]
"""
def get_classpath(lib, mcDir):
cp = []
for i in lib["libraries"]:
if not should_use_library(i):
continue
libDomain, libName, libVersion = i["name"].split(":")
jarPath = os.path.join(mcDir, "libraries", *
libDomain.split('.'), libName, libVersion)
native = get_natives_string(i)
jarFile = libName + "-" + libVersion + ".jar"
if native != "":
jarFile = libName + "-" + libVersion + "-" + native + ".jar"
cp.append(os.path.join(jarPath, jarFile))
cp.append(os.path.join(mcDir, "versions", lib["id"], f'{lib["id"]}.jar'))
return os.pathsep.join(cp)
version = '1.16.5'
username = '{username}'
uuid = '{uuid}'
accessToken = '{token}'
mcDir = os.path.join(os.getenv('HOME'), '.minecraft')
nativesDir = os.path.join(os.getenv('HOME'), 'versions', version, 'natives')
clientJson = json.loads(
Path(os.path.join(mcDir, 'versions', version, f'{version}.json')).read_text())
classPath = get_classpath(clientJson, mcDir)
mainClass = clientJson['mainClass']
versionType = clientJson['type']
assetIndex = clientJson['assetIndex']['id']
debug(classPath)
debug(mainClass)
debug(versionType)
debug(assetIndex)
subprocess.call([
'/usr/bin/java',
f'-Djava.library.path={nativesDir}',
'-Dminecraft.launcher.brand=custom-launcher',
'-Dminecraft.launcher.version=2.1',
'-cp',
classPath,
'net.minecraft.client.main.Main',
'--username',
username,
'--version',
version,
'--gameDir',
mcDir,
'--assetsDir',
os.path.join(mcDir, 'assets'),
'--assetIndex',
assetIndex,
'--uuid',
uuid,
'--accessToken',
accessToken,
'--userType',
'mojang',
'--versionType',
'release'
])
答案 3 :(得分:2)
这些都是在文本框中使用这些凭据启动标准minecraft启动器的所有方法。
以前有一种方法可以在没有启动器的情况下使用命令行登录到我的世界,但它已被修补。
如果你想使用命令行制作自定义启动器那么祝你好运, 登录Minecraft jar的唯一方法(IE:启动器执行的方式)是使用用户名,密码,启动器版本向https://login.minecraft.net/发送帖子请求, 和RSA密钥。然后它解析伪Json,并使用其中的会话令牌通过一系列参数从命令行验证jar。
如果您正在尝试制作一个Minecraft启动器并且您不了解java,http请求或者json,那么您就没有机会。
夫特
答案 4 :(得分:1)
只需在游戏目录中创建此批处理命令文件即可。
Bat文件使用一个参数%1作为用户名。
此外,我使用闪屏制作漂亮。
你将无法在线玩,但谁在乎。
调整内存使用情况以适合您的机器(-Xmx和-Xmns)。
注意:这是针对2016-06-27的Minecraft版本
@ECHO OFF
SET DIR=%cd%
SET JAVA_HOME=%DIR%\runtime\jre-x64\1.8.0_25
SET JAVA=%JAVA_HOME%\bin\java.exe
SET LOW_MEM=768M
SET MAX_MEM=2G
SET LIBRARIES=versions\1.10.2\1.10.2-natives-59894925878961
SET MAIN_CLASS=net.minecraft.client.main.Main
SET CLASSPATH=libraries\com\mojang\netty\1.6\netty-1.6.jar;libraries\oshi-project\oshi-core\1.1\oshi-core-1.1.jar;libraries\net\java\dev\jna\jna\3.4.0\jna-3.4.0.jar;libraries\net\java\dev\jna\platform\3.4.0\platform-3.4.0.jar;libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar;libraries\net\sf\jopt-simple\jopt-simple\4.6\jopt-simple-4.6.jar;libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar;libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar;libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar;libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar;libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar;libraries\io\netty\netty-all\4.0.23.Final\netty-all-4.0.23.Final.jar;libraries\com\google\guava\guava\17.0\guava-17.0.jar;libraries\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;libraries\commons-io\commons-io\2.4\commons-io-2.4.jar;libraries\commons-codec\commons-codec\1.9\commons-codec-1.9.jar;libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar;libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar;libraries\com\google\code\gson\gson\2.2.4\gson-2.2.4.jar;libraries\com\mojang\authlib\1.5.22\authlib-1.5.22.jar;libraries\com\mojang\realms\1.9.3\realms-1.9.3.jar;libraries\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar;libraries\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar;libraries\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar;libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar;libraries\it\unimi\dsi\fastutil\7.0.12_mojang\fastutil-7.0.12_mojang.jar;libraries\org\apache\logging\log4j\log4j-api\2.0-beta9\log4j-api-2.0-beta9.jar;libraries\org\apache\logging\log4j\log4j-core\2.0-beta9\log4j-core-2.0-beta9.jar;libraries\org\lwjgl\lwjgl\lwjgl\2.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar;libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar;versions\1.10.2\1.10.2.jar
SET JAVA_OPTIONS=-server -splash:splash.png -d64 -da -dsa -Xrs -Xms%LOW_MEM% -Xmx%MAX_MEM% -XX:NewSize=%LOW_MEM% -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -XX:+DisableExplicitGC -Djava.library.path=%LIBRARIES% -cp %CLASSPATH% %MAIN_CLASS%
start /D %DIR% /I /HIGH %JAVA% %JAVA_OPTIONS% --username %1 --version 1.10.2 --gameDir %DIR% --assetsDir assets --assetIndex 1.10 --uuid 2536abce90e8476a871679918164abc5 --accessToken 99abe417230342cb8e9e2168ab46297a --userType legacy --versionType release --nativeLauncherVersion 307
答案 5 :(得分:1)
要使用Forge运行Minecraft(将C:\Users\nov11\AppData\Roaming/.minecraft/
更改为MineCraft路径:) [仅适用于那些懒得在Google上搜索的人...]
特别感谢ammarx的TagAPI_3 (Github)(用于创建此命令)。
参数逐行分隔,以便更轻松地找到有用的参数。
java
-Xms1024M
-Xmx1024M
-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
-Djava.library.path=C:\Users\nov11\AppData\Roaming/.minecraft/versions/1.12.2/natives
-cp
C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/minecraftforge/forge/1.12.2-14.23.5.2775/forge-1.12.2-14.23.5.2775.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/ow2/asm/asm-all/5.2/asm-all-5.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/jline/jline/3.5.1/jline-3.5.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/typesafe/akka/akka-actor_2.11/2.3.3/akka-actor_2.11-2.3.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/typesafe/config/1.2.1/config-1.2.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-actors-migration_2.11/1.1.0/scala-actors-migration_2.11-1.1.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-compiler/2.11.1/scala-compiler-2.11.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/plugins/scala-continuations-library_2.11/1.0.2/scala-continuations-library_2.11-1.0.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/plugins/scala-continuations-plugin_2.11.1/1.0.2/scala-continuations-plugin_2.11.1-1.0.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-library/2.11.1/scala-library-2.11.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-parser-combinators_2.11/1.0.1/scala-parser-combinators_2.11-1.0.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-reflect/2.11.1/scala-reflect-2.11.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-swing_2.11/1.0.1/scala-swing_2.11-1.0.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/scala-lang/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/lzma/lzma/0.0.1/lzma-0.0.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/java3d/vecmath/1.5.2/vecmath-1.5.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/maven/maven-artifact/3.5.3/maven-artifact-3.5.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/mojang/patchy/1.1/patchy-1.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/paulscode/codecwav/20101023/codecwav-20101023.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/io/netty/netty-all/4.1.9.Final/netty-all-4.1.9.Final.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/google/guava/guava/21.0/guava-21.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/commons-io/commons-io/2.5/commons-io-2.5.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/commons-codec/commons-codec/1.10/commons-codec-1.10.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/mojang/authlib/1.5.25/authlib-1.5.25.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/mojang/realms/1.10.22/realms-1.10.22.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/lwjgl/lwjgl/lwjgl/2.9.2-nightly-20140822/lwjgl-2.9.2-nightly-20140822.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.2-nightly-20140822/lwjgl_util-2.9.2-nightly-20140822.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/libraries/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.jar;C:\Users\nov11\AppData\Roaming/.minecraft/versions/1.12.2/1.12.2.jar
net.minecraft.launchwrapper.Launch
--width
854
--height
480
--username
Ishikawa
--version
1.12.2-forge1.12.2-14.23.5.2775
--gameDir
C:\Users\nov11\AppData\Roaming/.minecraft
--assetsDir
C:\Users\nov11\AppData\Roaming/.minecraft/assets
--assetIndex
1.12
--uuid
N/A
--accessToken
aeef7bc935f9420eb6314dea7ad7e1e5
--userType
mojang
--tweakClass
net.minecraftforge.fml.common.launcher.FMLTweaker
--versionType
Forge
仅在其他解决方案不起作用时。可以从Mojang服务器获取accessToken和uuid,请查看其他辅助工具以了解详细信息。
编辑(26.11.2018): 我还用C#(.NET Framework 3.5)创建了启动器框架,您也可以检查启动器应如何工作 Available Here