那么,你知道 QSL 中有一个非常棒、经过实战考验且快速的资源加载系统吗?它被所有模组所使用。如果我们能直接复用这套系统,而不是需要一个臃肿的、依赖 Architectury 的过度工程化的混乱代码,而且稍微有点风吹草动就会出错,那该多好?
这就是本模组的作用。1.0 版本仅包含 10 行 Java 代码(含格式化):
new File("resources").mkdirs();
for (var t : ResourceType.values()) {
ResourceLoader.get(t).getRegisterTopResourcePackEvent().register((ctx) -> {
ctx.addResourcePack(new ModNioResourcePack(
"QDResLoader resources", mod.metadata(), null, ResourcePackActivationType.ALWAYS_ENABLED,
new File("resources").toPath(), t, null
));
});
}
自 1.0 版本以来,为了提升易用性并增加一些额外功能,我们添加了一些新特性,但整体依然保持精简;只是不再像“把整个模组塞进描述里”那样极致小巧了。
利用 resources 目录中的 QSL 资源加载器(QSL Resource Loader)的强大功能。你已经熟悉其格式:数据放入 data,资产放入 assets。也许你有一些不想解压的 zip 文件,或者因为你正在使用 Packwiz 来更新由他人管理的打包文件?没问题,将它们放入 packs 即可。
首次运行时,会在 resources 目录下生成一个 QDResLoader-README.txt 文件,为你提供快速的使用指南。内容如下:
此目录由 QDResLoader 创建和管理。当存在以下任一情况时,你可以删除此 README 文件。
此目录本身既作为数据包(datapack)也作为资源包(resourcepack)加载,因此任何 pack.mcmeta 都将被考虑处理(如果不存在,则使用 QSL 提供的默认值),并且“data”中的数据以及客户端上的“assets”中的资源都将被加载。
你还可以创建一个“packs”目录,并将目录、zip 文件或 jar 文件放入其中,它们都将作为打包文件加载。为了方便组织,你还可以创建“datapacks”或“resourcepacks”目录——这些目录中的打包文件将仅以单一类型加载,而不是同时作为两种类型加载。
主目录中的资源无法被用户禁用,但它们会显示在“资源包”和“数据包”菜单中,并且可以重新排序。所有三个打包目录中的打包文件都可以按用户意愿禁用,但默认情况下均为启用状态。
Jar 文件会被识别为打包文件,因此你可以将“数据包即模组(datapack-as-mod)”类型的 JAR 文件直接放在这里,而不是放在 mods 文件夹中,如果你希望这样做的话。
So, you know how there's this really nice, battle-tested, and fast resource loading system in QSL? It's used for every mod. Wouldn't it be great if we could just reuse that, instead of needing a bloated Architectury-requiring overengineered mess that breaks when you so much as breathe on it?
That's what this is. 1.0 is 10 lines of Java code, including formatting:
new File("resources").mkdirs();
for (var t : ResourceType.values()) {
ResourceLoader.get(t).getRegisterTopResourcePackEvent().register((ctx) -> {
ctx.addResourcePack(new ModNioResourcePack(
"QDResLoader resources", mod.metadata(), null, ResourcePackActivationType.ALWAYS_ENABLED,
new File("resources").toPath(), t, null
));
});
}
Since 1.0, some more features have been added to make it nicer to use and have some extra functionality, but it's still tiny regardless; just not "put the whole mod in your description" levels of tiny.
Harness the power of QSL Resource Loader in the resources directory. You already know the format; data goes in data, assets go in assets. Maybe you've got some zips you don't want to extract, maybe since you're managing them with Packwiz to update packs someone else manages? Cool, drop them in packs.
On first run, a QDResLoader-README.txt file will be dropped into resources to give you a quick explainer on how to use the mod. Here's what it says:
This directory is created and handled by QDResLoader. You can delete this README once any of the following things exist.
This directory itself is loaded as a datapack and resourcepack, so any pack.mcmeta will be considered (using a default provided by QSL if not present) and any data in "data", as well as resources in "assets" on the client, will be loaded.
You may also create a "packs" directory, and put directories, zips, or jars in there that will all be loaded as packs. For organization purposes, you may also create a "datapacks" or "resourcepacks" directory -- packs in those directories will only be loaded as one type instead of both.
The resources in the main directory cannot be disabled by users, but will be visible in the "Resource Packs" and "Data Packs" menu, and can be reordered. Packs in all three pack directories can be disabled as the user pleases, but are all enabled by default.
Jars are recognized as packs so you can take "datapack-as-mod" JARs and drop them here instead of in mods, if that's something you would like to do.
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
下载 QDResLoader
- 由 EnnuiL 更新至 1.20,感谢!
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
模组
添加区块认领和玩家组队功能,并与 Xaero's Minimap 和 World Map 集成
评论 0
登录后参与评分
还没有评论,来抢沙发吧