How do I make a loot table in Minecraft give one of several items?

How do I make a loot table in Minecraft give me one of several items? I'm setting up a data pack where every player gets a random item every ten seconds, and want it to be less resource-intensive. I want it to drop one random item every time.


Solution 1:

You would use multiple entries in a pool. For example, if you wanted it to give stone or dirt, you would use this:

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

For type, refer to this from the wiki:

type: Optional type of the loot table. Must be one of empty if the loot table does not generate any loot, entity for loot an entity drops, block for loot a block drops, chest for a treasure chest, fishing for a fishing loot table, advancement_reward if it's used as a reward for an advancement or generic if none of the above apply.


See the wiki for more information.