Skip to content

JSON Fragment

Fragment is a reusable JSON element that can be attached to your Lychee recipes.

Quilt Note

This feature is NOT available for Quilt Loader.

Define

All fragments should be defined in the lychee_fragments folder in a data pack, as a JSON file.

{
    "value": "Here can be any type of element"
}

Note

Fragments can be nested.

Use Fragment

First let's assume we have such a fragment:

lychee_fragments/gems.json
{
    "value": [
        {
            "type": "drop_item",
            "item": "diamond"
        },
        {
            "type": "drop_item",
            "item": "emerald"
        }
    ]
}

Replace the Current Element

{
    "post": {
        "@": "gems"
    }
}
{
    "post": [
        {
            "type": "drop_item",
            "item": "diamond"
        },
        {
            "type": "drop_item",
            "item": "emerald"
        }
    ]
}

Spread Elements to the Parent

{
    "post": [
        {
            "...@": "gems"
        },
        {
            "type": "prevent_default"
        }
    ]
}
{
    "post": [
        {
            "type": "drop_item",
            "item": "diamond"
        },
        {
            "type": "drop_item",
            "item": "emerald"
        },
        {
            "type": "prevent_default"
        }
    ]
}

Use Variables

You can define variables together with the fragment path, and reference it in the fragment.

{
    "comment": {
        "@": "comment",
        "name": "Fragment"
    },
    "post": [
        {
            "...@": "gems",
            "amount": 3
        },
        {
            "type": "prevent_default"
        }
    ]
}
{
    "value": [
        {
            "type": "drop_item",
            "item": "diamond",
            "count": "$amount"
        },
        {
            "type": "drop_item",
            "item": "emerald",
            "count": "$amount"
        }
    ]
}
{
    "value": "An example of ${name}"
}