-2

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! :)

  • What did you try yourself so far? It should be pretty straightforward with a block loot table, that feature was explicitly added for exactly that. – Fabian Röling Nov 18 at 9:06
  • @FabianRöling Thank you for your answer! I tried to create a loot table for the grass-block in /data/loot_tables/blocks/grass_block.json and there i changed the rolls option to 2 instead of one. But this didnt worked – Jonathan Nov 18 at 9:15
  • @FabianRöling maybe you could show me how to create a block loot table? Because I dont know how to do it – Jonathan Nov 18 at 9:17
  • Then you should ask about your specific loot table problem instead, with as much detail as possible. Also, that was a comment, not an answer. – Fabian Röling Nov 18 at 10:41
  • 1
    I linked you exactly to the section where they show the tree graph of datapacks! – Fabian Röling Nov 19 at 8:24
1

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.

  • Thank you verry much! I will try it out and when it works i will accept your answer :) – Jonathan Nov 18 at 9:28
  • I tried your solution but it didnt worked :( So did you tried your own? – Jonathan Nov 18 at 17:26
  • I destroyed grass blocks but didnt get back 10 blocks of dirt. Maybe when you get it working at you, could you send me the datapack? – Jonathan Nov 19 at 7:51
  • @Jonathan Sorry, I forgot the blocks folder in loot_tables. I updated the file name in my answer. Try that and see if that works. – cherryblossom Nov 19 at 10:06
  • thx, I will try it out :) – Jonathan Nov 19 at 10:17
0

As I said in the comments, I'm not an expert in datapacks at all, but just from looking at the wiki and the Vanilla loot tables I've created a datapack that works.

Folder structure:

saves
└<world_name>
 └datapacks
  └<datapack_name>
   └pack.mcmeta
   └data
    └minecraft
     └loot_tables
      └blocks
       └grass_block.json

Contents of pack.mcmeta:

{"pack":{"pack_format":3,"description":""}}

Contents of grass_block.json:

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:match_tool",
                  "predicate": {
                    "enchantments": [
                      {
                        "enchantment": "minecraft:silk_touch",
                        "levels": {
                          "min": 1
                        }
                      }
                    ]
                  }
                }
              ],
              "name": "minecraft:grass_block"
            },
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:survives_explosion"
                }
              ],
              "name": "minecraft:dirt",
              "functions":[
                {
                    "function": "minecraft:set_count",
                    "count": {
                        "min": 10.0,
                        "max": 10.0
                    }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

This is likely way more than you actually need, but it works. Going from there you can experiment with leaving stuff out and seeing what breaks it or not. (And please tell me then!)

  • Thank you that you took time to find a solution! I will try it out when I will be at home this evening :) – Jonathan Nov 21 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.