跳到正文

DisplayDelightJS

作者:nhjr

The ability to register more placable foods in 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)

Two working food display block and its original item

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.

常见问题

DisplayDelightJS 支持哪些 Minecraft 版本?

DisplayDelightJS 支持 Minecraft Java 版 1.21.1,可用的加载器:NeoForge。下载时注意选择和你游戏版本一致的文件。

DisplayDelightJS 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。

评论

登录后评论和评分