运行此模组前须知
本模组专为高级 Minecraft 用户 / 模组开发者设计。如果你不了解 Java 如何处理程序参数,请勿使用它。
警告:通过加载此模组可执行任何命令,包括恶意命令。作者不对因运行此模组导致的任何后果负责。
模组简介
这是一个简单但功能强大的工具,用于覆盖 Java 程序参数。
使用方法
本模组使用两个 Java 属性:rege.rege.misc.javaprogargoverride.Util.overridingArgs(下文为方便起见简称为 overridingArgs)和 rege.rege.misc.javaprogargoverride.Util.overridingArgsType(下文为方便起见简称为 overridingArgsType)。
以下是一个适用于客户端的简单示例:
1. 在 Minecraft 实例的根目录下创建 overrideargs.py,内容如下:
#!/usr/bin/env python
from sys import stdin, stdout
stdout.write(stdin.read())
stdout.write(" --fullscreen")
2. 编辑 Java 属性参数(例如 Prism Launcher 中的“设置/Java 参数”),添加以下内容:-Drege.rege.misc.javaprogargoverride.Util.overridingArgs="python overrideargs.py" -Drege.rege.misc.javaprogargoverride.Util.overridingArgsType=exec。
3. 启动游戏,你会发现 Minecraft 窗口以全屏状态创建。
对示例的解释:
- 本模组首先会检查是否存在属性
overridingArgs。如果不存在,本模组将不执行任何操作。 - 属性
overridingArgsType有两种可用类型:plain和exec。默认为plain。如果是plain,则overridingArgs指定的参数将直接作为覆盖参数使用,格式为 UNIX Shell 风格。如果是exec,则overridingArgs指定的参数将作为命令执行(类似 Batch / Shell 命令),待覆盖的参数将以 UNIX Shell 风格传入 STDIN。该命令的标准输出(STDOUT)将被用作覆盖参数,格式为 UNIX Shell 风格。- 例如,原始参数字符串
arg1 'arg2' "arg3" \a\r\g\4将被解析为 4 个参数arg1、arg2、arg3和arg4;原始参数字符串arg\\1 'arg\\2' "arg\\3" 'a'"r"g\''4' ""将被解析为 5 个参数arg\1、arg\\2、arg\3、arg'4和 ``(空字符串);原始参数字符串"arg\"1" 'arg'\'"2" "arg\\\\3" arg\ \\4将被解析为 4 个参数arg"1、arg'2、arg\\3和arg \4。 - 例如,参数
--width、1800、--height和1200将以--width 1800 --height 1200的形式传入 STDIN;参数--version、 ``(空字符串)、--gameDir和/home/this/is/a/path/with/"doubles"/'singles'/and/s p a c e s/and/even/\backslashes\将以--version '' --gamedir /home/this/is/a/path/with/\"doubles\"/\'singles\'/and/s\ p\ a\ c\ e\ s/and/even/\\backslashes\\的形式传入 STDIN。
- 例如,原始参数字符串
- 建议仅追加参数(例如在 Python 中使用
sys.stdout.write(sys.stdin.read()),在 Java 中使用System.out.write(System.in.readAllBytes()),在 Shell 脚本中使用cat -来输出原始参数)。但如果你愿意,也可以充分利用这些参数!
注意事项
本模组为“客户端可选,服务端可选”,且本模组的客户端版本和服务端版本独立工作,彼此之间没有关联。
客户端模组的 JAR 包不会在服务端运行,反之亦然。请确保你在正确的端运行正确版本的模组 JAR 包。
如果参数格式(由 overridingArgs 指定,或在 overridingArgsType 为 exec 时的 STDOUT 输出)不正确,Minecraft 将会崩溃:
- 引号未闭合,例如:如果原始参数字符串为
python "overrideargs.py,将抛出java.lang.IllegalArgumentException: quote at index 7 not closed。 - 原始参数字符串末尾出现意外转义字符(
\),例如:如果原始参数字符串为python overrideargs.py\,将抛出java.lang.IllegalArgumentException: unexpected escape at the end。 - 未找到命令,例如:如果原始参数字符串为
pyhon overrideargs.py,将抛出java.io.IOException: Cannot run program "pyhon": error=2, No such file or directory(具体信息可能因操作系统而异)。
报告问题
请在 这个 gist 下留下关于你问题的评论。
Before Running This Mod
This mod is designed for advanced Minecraft users / mod developers. If you do not know how Java handles Program arguments, don't run it.
WARN: ANY COMMAND CAN BE EXECUTED THROUGH THIS MOD LOADING, INCLUDING WHICH IS MALICIOUS. THE AUTHOR WILL NOT BE RESPONSIBLE FOR ANYTHING CAUSED BY RUNNING THIS MOD.
Mod Synopsis
This mod is a simple but powerful tool for overriding Java Program arguments.
How to Use This Mod
This mod uses 2 Java Properties: rege.rege.misc.javaprogargoverride.Util.overridingArgs (called overridingArgs below for convenience) and rege.rege.misc.javaprogargoverride.Util.overridingArgsType (called overridingArgsType below for convenience).
This is a simple example that works (for client-side):
1. Create overrideargs.py at the root directory of the Minecraft instance with following content:
#!/usr/bin/env python
from sys import stdin, stdout
stdout.write(stdin.read())
stdout.write(" --fullscreen")
2. Edit the content of Java Properties arguments (e.g. “Settings/Java arguments” in Prism Launcher), add these: -Drege.rege.misc.javaprogargoverride.Util.overridingArgs="python overrideargs.py" -Drege.rege.misc.javaprogargoverride.Util.overridingArgsType=exec.
3. Launch the game, and you will find that the Minecraft window is created in a fullscreen state.
Explanation of the example:
- This mod will first check whether Property
overridingArgsis present. If no, this mod will do nothing. - There are 2 types available for Property
overridingArgsType:plainandexec. The default isplain. If it isplain, then the arguments specified byoverridingArgswill be directly used as the overriding arguments, in UNIX-Shell-styled format. If it isexec, then the arguments specified byoverridingArgswill be executed as a command (like Batch / Shell commands), the arguments to be overridden will be passed into STDIN in UNIX-Shell-styled format. The STDOUT of the command will be used as the overriding arguments, in UNIX-Shell-styled format.- For example, raw argument string
arg1 'arg2' "arg3" \a\r\g\4will be resolved as 4 argumentsarg1,arg2,arg3andarg4; raw argument stringarg\\1 'arg\\2' "arg\\3" 'a'"r"g\''4' ""will be resolved as 5 argumentsarg\1,arg\\2,arg\3,arg'4and ``(empty string); raw argument string"arg\"1" 'arg'\'"2" "arg\\\\3" arg\ \\4will be resolved as 4 argumentsarg"1,arg'2,arg\\3andarg \4. - For example, arguments
--width,1800,--heightand1200will be passed to STDIN as--width 1800 --height 1200; arguments--version, ``(empty string),--gameDirand/home/this/is/a/path/with/"doubles"/'singles'/and/s p a c e s/and/even/\backslashes\will be passed to STDIN as--version '' --gamedir /home/this/is/a/path/with/\"doubles\"/\'singles\'/and/s\ p\ a\ c\ e\ s/and/even/\\backslashes\\.
- For example, raw argument string
- Appending arguments only is recommended (output the original arguments by using e.g.
sys.stdout.write(sys.stdin.read())in Python,System.out.write(System.in.readAllBytes())in Java andcat -in Shell Script). But if you want, you can even make full use of the arguments!
Notice
This mod is “Client-side optional, Server-side optional”, and client-side and server-side version of this mod work independently, and they have nothing to do with each other.
The client-side mod JAR will not be run on the server-side and vice versa. Please ensure you are running the correct version of the mod JAR on the correct side.
If the argument format (by overridingArgs or the STDOUT when overridingArgsType is exec) is incorrect, Minecraft will crash:
- Quote not close, for example: If the raw argument string is
python "overrideargs.py,java.lang.IllegalArgumentException: quote at index 7 not closedwill be thrown. - Unexpected escape character(
\) at the end of the raw argument string, for example: If the raw argument string ispython overrideargs.py\,java.lang.IllegalArgumentException: unexpected escape at the endwill be thrown. - Command not found, for example: If the raw argument string is
pyhon overrideargs.py,java.io.IOException: Cannot run program "pyhon": error=2, No such file or directory(may vary by operating system) will be thrown.
Report Issues
Please leave a comment about your issue under the gist.
下载 JavaProgArgOverride
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 JavaProgArgOverride
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 JavaProgArgOverride
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
JavaProgArgOverride 的第 1 个版本。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧