Minecraft Datapack drop X blocks instead of One when Destroying any block

I want to create a Datapack. My goal is to drop more than one items when destroying a block in Minecraft.

For example: When I destroy a grass-block it drops default One dirt-block. But I want (for example) 10 dirt blocks get dropped when I destroy a grass block.

How do I achieve this?

Many thanks for your help! :)


Use loot tables. For your example, save this as data_pack_name/data/minecraft/loot_tables/blocks/grass_block.json.

{
  "type": "block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "item",
          "name": "dirt",
          "functions": [
            {
              "function": "set_count",
              "count": 10
            }
          ]
        }
      ]
    }
  ]
}

However, that would also remove the ability to get a grass block using Silk Touch.

For more detailed information, see the wiki.