Here is an example of a loot table that might work. If it does, it'll need some extra steps. This loot table is able to match the ammo and guns together (or in this case, arrows with bows and fireworks with crossbows) by putting the decision into a scoreboard. To use this, first use /execute store result score target_name target_objective run random range 0..1
with the /random command (added in 1.20.2) to generate a random number within the range of different ammos you have. Then, the loot table will read this numbers and choose the first item that has the specific condition that matches the scoreboard. To add more items independent of the ammo and gun conditions, put them in a separate pool (not the first or second).
You can replace "target_name" and "target_objective" with whatever you want. To add more ammos or guns, just copy the previous items that use the value_check, but remember to increase the range in the random command or they won't be rolled.
{
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"name": "minecraft:arrow",
"conditions": [
{
"condition": "minecraft:value_check",
"value": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "target_name"
},
"score": "target_objective"
},
"range": 0
}
]
},
{
"type": "minecraft:item",
"name": "minecraft:firework_rocket",
"conditions": [
{
"condition": "minecraft:value_check",
"value": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "target_name"
},
"score": "target_objective"
},
"range": 1
}
]
}
]
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"name": "minecraft:bow",
"conditions": [
{
"condition": "minecraft:value_check",
"value": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "target_name"
},
"score": "target_objective"
},
"range": 0
}
]
},
{
"type": "minecraft:item",
"name": "minecraft:crossbow",
"conditions": [
{
"condition": "minecraft:value_check",
"value": {
"type": "minecraft:score",
"target": {
"type": "minecraft:fixed",
"name": "target_name"
},
"score": "target_objective"
},
"range": 1
}
]
}
]
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:stone"
}
]
}
]
}