Skip to content

Instantly share code, notes, and snippets.

@Dinnerbone
Created October 19, 2015 16:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Dinnerbone/16a5543bb6bea24af227 to your computer and use it in GitHub Desktop.
Save Dinnerbone/16a5543bb6bea24af227 to your computer and use it in GitHub Desktop.
This is an example of the current spawn bonus chest loot table in Minecraft, in the (possibly) new loot table data format.
[
{
"item": "minecraft:stick",
"weight": 10,
"functions": [
{
"function": "minecraft:set_count",
"min": 1,
"max": 3
}
]
},
{
"item": "minecraft:planks",
"weight": 10,
"functions": [
{
"function": "minecraft:set_count",
"min": 1,
"max": 3
}
]
},
{
"item": "minecraft:log",
"weight": 10,
"functions": [
{
"function": "minecraft:set_count",
"min": 1,
"max": 3
}
]
},
{
"item": "minecraft:stone_axe",
"weight": 3
},
{
"item": "minecraft:wooden_axe",
"weight": 5
},
{
"item": "minecraft:stone_pickaxe",
"weight": 3
},
{
"item": "minecraft:wooden_pickaxe",
"weight": 5
},
{
"item": "minecraft:apple",
"weight": 5,
"functions": [
{
"function": "minecraft:set_count",
"min": 2,
"max": 3
}
]
},
{
"item": "minecraft:bread",
"weight": 3,
"functions": [
{
"function": "minecraft:set_count",
"min": 2,
"max": 3
}
]
},
{
"item": "minecraft:log2",
"weight": 10,
"functions": [
{
"function": "minecraft:set_count",
"min": 1,
"max": 3
}
]
}
]
@koosemose
Copy link

Looks good.

And this is definitely the best way to do weighted chance, it's the only method I've seen of doing weights, if it's floats that add up to 1 it's not weights, it's percentage chance. Though I rather hope the weights are floats rather than ints, so if someone, for example, wanted to go back in and add extremely rare loot they could do so without having to change all the weights (with this table as a basis, just add an item with a weight of .1 rather than having to multiply all current weights by 10 and adding an item with weight 1 for the same end result).

I am also assuming that it will be possible to include items with NBT data, since that would be required to have things like enchanted books that are currently in loot chests.

It would also be nice to have some form of sub tables, such that if I for example wanted an option to have enchanted swords with some combination of sharpness, unbreakable, and looting I could instead tell it to have a sword, with whatever base data I want on it, and then have it add between 0 and 3 (with varying weights) enchantments out of those 3, rather than needing to list separately all combinations of those 3 enchantments.

And a fine request/suggestion/hope, the ability to set certain items to be mutually exclusive, such that I could have a loot table that could give you either a sword or an ax but not both along with a completely random assortment of other items. Though now that I think of it that could probably be achieved with sub-tables, if one of the possible entries is 1 result from a subtable that has either a sword or an axe as options, that would achieve the desired result.

@HenryLoenwind
Copy link

Please be kind to us modders and add a method to register additional tables to be merged with with the in-memory table from the beginning.

@riddle
Copy link

riddle commented Oct 20, 2015

@Dinnerbone When we were writing our own plugins, we created a loot table format much more versatile than this. I understand you wanna do JSON, but maybe look at what could be possible:

https://github.com/CoreNetwork/Mantle/wiki/Loot-table-format

Example of actual loot tables

@Wombosvideo
Copy link

gistcomment-1599786 totally with you

@mhmd223
Copy link

mhmd223 commented Oct 20, 2015

hi

@towerofnix
Copy link

Looking awesome!

Do we have a list of functions somewhere? Can they also be edited?

@towerofnix
Copy link

I hacked around a little and have found this code, for anybody who wants to see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment