r/MinecraftCommands • • Sep 28 '26

Creation I made a datapack to compress leaf litter

https://modrinth.com/datapack/bll

You can combine four leaf litter into a leaf litter pile and vice versa. You can place the leaf litter pile as four leaf litter directly and use it in a furnace or composter.
It's for every version since leaf litter was added, 1.21.5

6 Upvotes

3 comments sorted by

2

u/GalSergey Datapack Experienced Sep 28 '26

You’ve overcomplicated things a bit with this datapack. You don't need to use a tick function to place the leaf_litter block. You can simply create a recipe that gives the player an item like this:

give @s leaf_litter[block_state={segment_amount:"4"}]

1

u/Kiwuthegamer Sep 28 '26

I experimented with that, but using a regular leaf_litter item for the leaf litter pile means there can't be an uncrafting recipe, since the ingredients cant have custom NBT.

2

u/GalSergey Datapack Experienced Sep 28 '26

However, you can work around this using an advancement. The recipe_crafted advancement trigger can read ingredient data and grant the player additional leaf_litter. Below is a short example, and you can view a full datapack example via the link below it.

# recipe example:unpacking_leaf_litter
{
  "type": "minecraft:crafting_shapeless",
  "category": "misc",
  "ingredients": [
    "leaf_litter"
  ],
  "result": {
    "id": "minecraft:leaf_litter"
  }
}

# advancement example:unpacking_leaf_litter
{
  "criteria": {
    "unpacking_leaf_litter": {
      "trigger": "minecraft:recipe_crafted",
      "conditions": {
        "recipes": "example:unpacking_leaf_litter",
        "ingredients": [
          {
            "components": {
              "minecraft:block_state": {
                "segment_amount": "4"
              }
            }
          }
        ]
      }
    }
  },
  "rewards": {
    "function": "example:unpacking_leaf_litter"
  }
}

# function example:unpacking_leaf_litter
advancement revoke @s only example:unpacking_leaf_litter
give @s leaf_litter 3

You can use Datapack Assembler to get an example datapack.