Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
}
]
}
]
@Nulcheck

This comment has been minimized.

Copy link

@Nulcheck Nulcheck commented Oct 19, 2015

hi

@XxMoNsTeR

This comment has been minimized.

Copy link

@XxMoNsTeR XxMoNsTeR commented Oct 19, 2015

Hi dinnerbone! Can you add vertical slabs to minecraft? And slab linking! #hugs #pls

@Fishrock123

This comment has been minimized.

Copy link

@Fishrock123 Fishrock123 commented Oct 19, 2015

This looks fairly sound.

A weight between 0 and 1 may be more easily understood though. (Where 0 is never and 1 is always)

@kukelekuuk

This comment has been minimized.

Copy link

@kukelekuuk kukelekuuk commented Oct 19, 2015

@Fishrock123

I disagree, with an integer weight I can easily divide the whole table in hundred, or thousand. Then I can just pretend it's percentages or per mils. It's all about how it's explained to the end user.

@ljfa-ag

This comment has been minimized.

Copy link

@ljfa-ag ljfa-ag commented Oct 19, 2015

Except that it doesn't really work (or is equally as unintuitive) when the weights don't add up to 1.

@manuelgu

This comment has been minimized.

Copy link

@manuelgu manuelgu commented Oct 19, 2015

Looks cool. Will add a new level of Map Making to the game. Especially Dungeon / Explore Maps can be improved quite a lot with that!

@Rubisk

This comment has been minimized.

Copy link

@Rubisk Rubisk commented Oct 19, 2015

Weight is very intuitive - if you want to add one item with an equal chance, just add it and you don't have to go and change the percentage of all other items ;-)

If you find it confusing - just make all weight add up to 100?

@Arcensoth

This comment has been minimized.

Copy link

@Arcensoth Arcensoth commented Oct 19, 2015

Using integer weights is the superior method. It allows you to seamlessly add items, remove items, and change existing items, without having to update anything else in the table. Anyone who has dealt with MobSpawners should understand. (In contrast, having weights between 0 and 1 that all add to 1 will potentially require you to go through and fix the entire table whenever a change is made.) As for intuition - @Rubisk is exactly right.

Anyway, awesome! I'm definitely looking forward to this feature, Dinnerbone. I was just about to start working on a randomized chest system using MobSpawners - but maybe I should hold back for the next few snapshots!

@caseif

This comment has been minimized.

Copy link

@caseif caseif commented Oct 19, 2015

@XxMoNsTeR Time and a place buddy. This is neither the time nor the place.

@koosemose

This comment has been minimized.

Copy link

@koosemose koosemose commented Oct 19, 2015

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

This comment has been minimized.

Copy link

@HenryLoenwind HenryLoenwind commented Oct 19, 2015

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

This comment has been minimized.

Copy link

@riddle 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

This comment has been minimized.

Copy link

@Wombosvideo Wombosvideo commented Oct 20, 2015

gistcomment-1599786 totally with you

@mhmd223

This comment has been minimized.

Copy link

@mhmd223 mhmd223 commented Oct 20, 2015

hi

@towerofnix

This comment has been minimized.

Copy link

@towerofnix towerofnix commented Oct 22, 2015

Looking awesome!

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

@towerofnix

This comment has been minimized.

Copy link

@towerofnix towerofnix commented Oct 22, 2015

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