
这是 Minecraft 模组的核心库。是的,我们知道,名字非常原创。
不管你信不信,在每个项目中复制粘贴一堆类既不是最高效的,也不是最稳定的主意。
Sol 为模组开发提供了一整套常用的代码工具。
其中大部分围绕数据、多加载器支持和渲染辅助功能展开。几个关键亮点如下:
简单的配置系统。
按需加载,易于设置,并且可以从其他模组中访问,无需硬依赖。
SolConfig config = MOD.createConfig("sollib/test", 1.0, builder -> builder
.addObject("category", category -> category
.comment("这是一个注释")
.add("hello", "world")
.add("easyconfig", true)
)
);
MOD.getLogger().info(config.get("category.hello", ""));
// world
由代码控制的运行时数据。
这允许你在运行时编辑数据包文件,可能根据配置值更改配方,如果目标模组未加载则编辑或禁用兼容配方,为动态定义的物品自动生成模型,以及更多功能。
SolRegistries.Data.RUNTIME.addJson(Identifier.of("minecraft", "recipe/dropper.json"), json -> {
if (json == null) return null;
if (!config.get("recipe.copper_dropper", false)) return null;
json.getAsJsonObject("key")
.getAsJsonObject("#")
.addProperty("item", "minecraft:copper_ingot");
return json;
});
渲染辅助功能。
集中化且与加载器无关。也不需要编写更多的 Mixin。
ResourceLocation TEXTURE = MOD.makeID("textures/models/sword_overlay.png");
SolClientRegistries.Render.ITEM.register(stack -> stack.is(Items.DIAMOND_SWORD) && stack.isEnchanted(),
(stack, context, matrices, bufferSource, light, overlay) -> {
matrices.scale(1.005f, 1.005f, 1.005f);
matrices.translate(0, 0.995, 0.4975);
matrices.mulPose(Axis.XP.rotationDegrees(180));
MockItemRenderer.renderItem(matrices, bufferSource, light, TEXTURE);
});
简化的注册表。
你可以在通用代码中调用它,包含所有你需要的语法糖:同时定义模型、燃烧时间、剥落结果以及关于某个特性的所有内容。
MOD.register(BlockHolder.class, "block_block", () -> new Block(BlockBehaviour.Properties.of()))
.withItem(item -> item.withFuel(200)).dropsSelf()
.withSlab().withStairs().withWall()
.withFlammability(20, 5);
对于普通用户来说,把页面做得多么花哨其实并不重要。毕竟这只是一个库。
但如果你是开发者并且对此感到好奇,最好的学习方式是阅读(进行中)Wiki 或加入 Discord。

This is a core library for Minecraft mods. Yes, we know, very original.
Believe it or not, copy-pasting a bunch of classes across every project is neither the most efficient nor the most stable idea.
Sol offers a whole constellation of common code for mod developpement.
Most of them orbit around data, multiloader and rendering helpers. A few key highlights being:
Easy config system.
Loaded as soon as you want it, easy to setup and accessible from other mods without the need for hard dependencies.
SolConfig config = MOD.createConfig("sollib/test", 1.0, builder -> builder
.addObject("category", category -> category
.comment("This is a comment")
.add("hello", "world")
.add("easyconfig", true)
)
);
MOD.getLogger().info(config.get("category.hello", ""));
// world
Runtime data, controlled by code.
This lets you edit datapack files at runtime, potentially allowing to change recipes depending on config values, edit or disable compat recipes if their target mods are not loaded, automatically generate models for dynamically defined items, and much more.
SolRegistries.Data.RUNTIME.addJson(Identifier.of("minecraft", "recipe/dropper.json"), json -> {
if (json == null) return null;
if (!config.get("recipe.copper_dropper", false)) return null;
json.getAsJsonObject("key")
.getAsJsonObject("#")
.addProperty("item", "minecraft:copper_ingot");
return json;
});
Rendering helpers.
Centralized and loader agnostic. No need to make more mixins, either.
ResourceLocation TEXTURE = MOD.makeID("textures/models/sword_overlay.png");
SolClientRegistries.Render.ITEM.register(stack -> stack.is(Items.DIAMOND_SWORD) && stack.isEnchanted(),
(stack, context, matrices, bufferSource, light, overlay) -> {
matrices.scale(1.005f, 1.005f, 1.005f);
matrices.translate(0, 0.995, 0.4975);
matrices.mulPose(Axis.XP.rotationDegrees(180));
MockItemRenderer.renderItem(matrices, bufferSource, light, TEXTURE);
});
Simplified registry.
That you can call in the common code, complete with all the syntax sugar you need: define models, burn time, stripping results and everything about a feature at the same time.
MOD.register(BlockHolder.class, "block_block", () -> new Block(BlockBehaviour.Properties.of()))
.withItem(item -> item.withFuel(200)).dropsSelf()
.withSlab().withStairs().withWall()
.withFlammability(20, 5);
For the average user, making this page as flashy as we can won't really matter. It's only a library after all.
But if you are a developer and are curious about it, the best way to learn is to read the (wip) Wiki or join the Discord.
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
下载 SolLib
暂无更新日志
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
一个用于收集生物掉落物的多区块模组。
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
查看物品与配方
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
AE2:一款流行的自动化与存储模组
评论 0
登录后参与评分
还没有评论,来抢沙发吧