2

I am trying to create a custom chest loot table and no matter what I try, it is not working. I have been researching this issue for 3 days now, and have had no success.

My pack is in this filepath:
...\datapacks\BattlePack\data\battle\loot_tables\chests\battle_gear.json

This is my pack.mcmeta:

{
    "pack": {
        "pack_format": 10,
        "description": "Battle Pack"
    }
}

Source

This is my battle_gear.json:

{
  "type": "minecraft:chests",
  "pools": [
    {
      "rolls": {
        "min": 5,
        "max": 10
      },
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:wooden_sword",
          "weight": 100
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:stone_sword",
          "weight": 75
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:golden_sword",
          "weight": 50
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:iron_sword",
          "weight": 60
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:wooden_axe",
          "weight": 75
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:stone_axe",
          "weight": 50
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:iron_axe",
          "weight": 20
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:diamond_sword",
          "weight": 100
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:bread",
          "weight": 100,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 5,
                "max": 8
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:porkchop",
          "weight": 60,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 5
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:beef",
          "weight": 55,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 6
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:cooked_beef",
          "weight": 20,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 4
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:apple",
          "weight": 99,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 5,
                "max": 12
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:golden_apple",
          "weight": 5,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 2
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:netherite_ingot",
          "weight": 6,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 2
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:dirt",
          "weight": 99,
          "functions": [
            {
              "function": "minecraft:set_data",
              "data": 0
            },
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 15,
                "max": 30
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:chainmail_chestplate",
          "weight": 30
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:leather_chestplate",
          "weight": 100
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:iron_chestplate",
          "weight": 20
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:golden_chestplate",
          "weight": 25
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:diamond",
          "weight": 15,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 0,
                "max": 8
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:leather_boots",
          "weight": 85
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:chainmail_boots",
          "weight": 55
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:golden_boots",
          "weight": 65
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:iron_boots",
          "weight": 75
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:iron_ingot",
          "weight": 65,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 5,
                "max": 20
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:log",
          "weight": 85,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 18
              }
            }
          ]
        },
        {
          "type": "minecraft:item",
          "name": "minecraft:book",
          "weight": 100,
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": {
                "min": 1,
                "max": 10
              }
            }
          ]
        }
      ]
    }
  ]
}

I used minecraft.tools for this generation, but cross referenced misode's generator to make sure that everything was still formated and named correctly (I just chose minecraft.tools for the simplicity, and it has worked for me in the past)

I have tried nearly every possible command I could find in order to get this chest into my world, and yet none have worked. This is the command I am currently trying, given that it was the most recent working answer I have found:
/setblock ~ ~1 ~ minecraft:chest{BlockEntityTag:{LootTable:"battle:chests/battle_gear"}} replace
Source

Absolutely nothing is working, and I only ever get an empty chest. I have checked everything several times over, and have found no faults, so I am really not sure what is going wrong. I also know that my datapack is loaded correctly, as it is listed in the /datapack list command and my load.mcfunction script runs.

1 Answer 1

1

minecraft.tools is an outdated generator that outputs files that only work on older versions of Minecraft.

With your loot table, there are three issues that prevent it from working properly:

  • Line 2: "type": "minecraft:chests" is not a valid loot table type. The correct type is minecraft:chest.
  • Lines 153–156: The minecraft:set_data loot table function no longer exists, as data values are no longer a thing since 1.13.
  • Line 236: minecraft:log is not a valid item ID. It used to be, but was removed.

Any of these issues on their own is enough to short out the entire loot table and prevent it from loading. The system is strict, and a single error will cause the entire file to be ignored.

In the future, it is recommended that you enable Minecraft's output log when developing data packs. The output log can be opened by checking the following checkbox in the Minecraft launcher before starting the game:

Output log checkbox in the Minecraft launcher

Any issues that cause a file load failure will be logged as a red message in the log, like so:

enter image description here

This example was run with the loot table provided in the question post, and we can see that the log is reporting the error caused by the invalid item function minecraft:set_data. Note that the log only reports the first error it finds in each file, so there may be more errors that appear after fixing the first.

Finally, I would recommend against minecraft.tools and suggest you to use misode.github.io, which is considered by many as the "gold standard" for data pack file generators, and is kept up to date regularly.

1
  • 1
    What a complete and thorough answer. Makes me want to learn how to write a custom loot table.
    – Phil DD
    Commented Nov 15, 2022 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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