Skip to content

JS Usage

nanhuajiaren edited this page Sep 4, 2026 · 1 revision

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");
});

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.

Clone this wiki locally