Skip to content

Instantly share code, notes, and snippets.

@misode
Last active June 16, 2020 16:43
Show Gist options
  • Save misode/728b6251adfcdef5f71e50e51e002059 to your computer and use it in GitHub Desktop.
Save misode/728b6251adfcdef5f71e50e51e002059 to your computer and use it in GitHub Desktop.

Loot Table Inherit

This is a proposal for a way to include the loot table that is being overwritten by the new data pack. This can be useful if you want to partially overwrite a vanilla loot table, but want it to be future proof. Or if you also want other data packs to be able to overwrite the same vanilla loot table. This is currently not possible.

The first data pack loads the initial loot table.

{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "item",
          "name": "stone"
        }
      ]
    }
  ]
}

A later data pack overwrites the loot table with the same name, but because it uses the inherit entry type, it will include the original loot table. In this example we want to drop a diamond if it's raining, otherwise drop the original loot table.

{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "alternative",
          "terms": [
            {
              "type": "item",
              "name": "diamond",
              "conditions": [
                {
                  "condition": "weather_check",
                  "raining": true
                }
              ]
            },
            {
              "type": "inherit"
            }
          ]
        }
      ]
    }
  ]
}

Just after loading, you can interpret the loot table as having the following structure.

{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "alternative",
          "terms": [
            {
              "type": "item",
              "name": "diamond",
              "conditions": [
                {
                  "condition": "weather_check",
                  "raining": true
                }
              ]
            },
            {
              "type": "inherit",
              "pools": [
                {
                  "rolls": 1,
                  "entries": [
                    {
                      "type": "item",
                      "name": "stone"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment