Display Delight 看起来很棒。不过,你的整合包中可能包含支持列表之外的其他模组,因此我引入了通过 KubeJS 注册更多可放置食物的功能。本模组专为整合包设计,欢迎在任何地方使用。
使用方法
Display Delight 不仅用于组织内容,还利用其命名规范来处理战利品表、物品放置等(详见 其 GitHub 页面)。对于没有盘子的食物,方块 ID 应遵循 abbr_food_name 格式;放在盘子上的食物应为 abbr_plated_food_name;而放在小盘子上的食物则为 abbr_small_plated_food_name。ID 注册错误的食物方块将无法按预期工作!
出于技术原因,完整的注册过程分为三个部分。在本演示中,我们以 Fruits Delight 中的几种物品为例:
- 首先在启动初始化阶段注册缩写到完整模组 ID 的映射:
StartupEvents.init(event => {
DisplayDelight.addCompatAbbr("frd", "fruitsdelight");
});
- 接着使用自定义
BlockBuilder 注册实际的食物方块:
StartupEvents.registry('block', event => {
event.create("frd_plated_cranberry_cookie", "displaydelight:stackable_plated")
.maxDisplayStack(4);
event.create("frd_glowberry_jello", "displaydelight:food");
});
完整的自定义 BlockBuilder 参考列表,请参阅 项目 Wiki 页面。大多数方法在自定义构建器中都能按预期工作,掉落表除外(Display Delight 使用硬编码的掉落表)。对于可堆叠的食物,请使用 maxDisplayStack() 设置最大堆叠数量。
ServerEvents.tags('item', event => {
event.add("displaydelight:plate_displayable", "fruitsdelight:cranberry_cookie");
event.add("displaydelight:displayable", "fruitsdelight:glowberry_jello");
});
对于不可堆叠的食物方块,模型资源位于其常规位置;对于可堆叠的食物方块,模型文件需使用 _1、_2 等后缀命名,直至最大堆叠数。在本示例中,所需的模型包括 block/frd_glowberry_jello.json、block/frd_plated_cranberry_cookie_1.json、block/frd_plated_cranberry_cookie_2.json、... block/frd_plated_cranberry_cookie_4.json。
Display Delight 的方块状态定义仅包含两部分:支撑结构和主模型。盘子模型被包含在模型中,而隐藏盘子的功能则是通过直接修改烘焙模型来实现的,而不是通过方块状态定义。在 Display Delight JS 中,你可以选择使用这两种方式之一。只需在方块注册表中调用 noModelModify(true),然后你就可以手动构建隐藏盘子的模型文件,路径为 block/<正常模型>_plate_hidden.json。
截至本次演示,我们现在拥有了两个完全可用的食物展示功能:(我不是艺术家,只是能正常工作)

对原版模组行为的更改
有几个基于配置的行为更改适用于原版模组(默认不启用;无需 KubeJS 即可使用)。我还将“出现在 ... 模组中”的工具提示从硬编码的模组名称改为使用翻译键。此更改不可配置。
Display Delight looks great. However, you might want to have some mods other than its support list in your modpack, so I've introduced the ability to register more placable foods with KubeJS. This mod is dedicated for modpacks, feel free to use it anywhere.
How to use this
Display Delight uses its naming convention (see its github page) not only for organizing, but also for loot table, item placing, etc. A food block id should look like abbr_food_name for foods without plate, and abbr_plated_food_name for foods on plates, and abbr_small_plated_food_name for foods on small plates. Food blocks registered in wrong id won't work as intended!
For technical reasons, a full registration is split in three parts. In this demo we use several items from Fruits Delight as an example:
- First register the abbr -> full modid map in startup init:
StartupEvents.init(event => {
DisplayDelight.addCompatAbbr("frd", "fruitsdelight");
});
- Second register the actual food block with a custom BlockBuilder:
StartupEvents.registry('block', event => {
event.create("frd_plated_cranberry_cookie", "displaydelight:stackable_plated")
.maxDisplayStack(4);
event.create("frd_glowberry_jello", "displaydelight:food");
});
For full custom BlockBuilder reference list, see project wiki page. Most methods should work as intended for the custom builder, except for loot tables (Display Delight uses hardcoded loot). For stackable food, use maxDisplayStack() to set the max count.
- Finally register the food item as placable by tag:
ServerEvents.tags('item', event => {
event.add("displaydelight:plate_displayable", "fruitsdelight:cranberry_cookie");
event.add("displaydelight:displayable", "fruitsdelight:glowberry_jello");
});
For non-stackable food block, the model assets are in their regular place; for stackable food block, the model use suffix _1, _2, ..., up to the maximum stack. As of this demo, the models required are block/frd_glowberry_jello.json, block/frd_plated_cranberry_cookie_1.json, block/frd_plated_cranberry_cookie_2.json, ... block/frd_plated_cranberry_cookie_4.json.
Display Delight only use two parts in its blockstate definition, the supports and the main model. The plate is contained in the model, and the plate hidden feature is implemented by directly modifying baked model, rather than blockstate definition. In Display Delight JS, it's possible to use both way. Just call noModelModify(true) in block registry, and you can manually build your plate hidden model at block/<normal model>_plate_hidden.json.
As of this demo, now we've got two fully working food display: (I'm not artist, it just works)

Changes to original mod behaviour
There are several configuration based behaviour change to the original mod (not active by default; available without KubeJS). I've also made the "Appers in ... mod" tooltip use translate keys instead of hardcoded values for mod names. This change isn't configurable.
评论 0
登录后参与评分
还没有评论,来抢沙发吧