Mod That Closes The Game When It Opens Mk.2
An experiment to make the smallest possible Fabric mod (with actual code). Does what the title says.
介绍
An experiment to make the smallest possible Fabric mod (with actual code). Does what the title says.
So what’t the drill?
The (self-imposed) rules are to make the smallest possible Fabric mod that “does something”. The definition of that in my opinion is to run, or at least attempt to, some code. So what can be done with that?
- The class.
public class i extends java.io.File {
public i() {
throw null;
}
}
Although it looks simple, this is not valid Java – the compiled bytecode was manually modified to make it throw a null, and to remove this parameter in the initializer. Also, by default all classes extend java.lang.Object, so it was changed to java.io.File to save two letters.
- Mod metadata Abusing the
fabric.mod.jsonformat, it can be compacted down to
{"id":"id","version":"i","initializer":"i"}
Back in 2019 Fabric used to have a different metadata format, which is still supported to this day! Thanks to it, the file doesn’t need a schemaVersion field, or the complex entrypoints setup.
- Build process There are two files, so there isn’t much to compress, but to squeeze the most of it, they are zipped with the zopfli compressor. It is possible to get a smaller file size with .xz format, but it wouldn’t be possible to load as a mod in that case.
- Runtime Well, there isn’t much code to “”do something”” – a no-op instruction would technically suffice, but I don’t think it’s interesting. So instead the code tries to throw an exception, and fails because it can’t throw null. Task failed successfully, I guess…
常见问题
Mod That Closes The Game When It Opens Mk.2 支持哪些 Minecraft 版本?
Mod That Closes The Game When It Opens Mk.2 支持 Minecraft Java 版 1.14–26.2,共 47 个版本,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。
Mod That Closes The Game When It Opens Mk.2 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端 / 服务端。
KikuGie 的其他作品
查看全部 →Elytra Trims
可自定义鞘翅模组,支持盔甲纹饰、旗帜图案等更多内容!
Elytra Trims Extensions
为其他整合包添加鞘翅纹饰。
Command Config Lib
基于命令的客户端与服务器配置库
Voice Chat Soundboard
为 Simple Voice Chat 添加客户端音效板。
评论
登录后评论和评分