Solved Realistic chest loot

Discussion in 'Spigot Plugin Development' started by dart2112, Jan 25, 2020.

  1. What I would like to do is make a class that generates the contents for loot chests in the most accurate way possible.
    That page has all of the information about items that can be found in chests and how probable they are. But I'm not quite sure how to codify it. Another thing is I'm not sure if someone else has already done this and I just can't find it.
    Any help with codifying it or finding a pre-existing version is much appreciated. Ideally, I'd like to be able to dump the values from gamepedia into a list of some kind and have the code use that as the probability table. but I haven't done anything like that before so I'm not really sure how to approach it.
  2. drives_a_ford


    What are you actually trying to do?
    Are you trying to generate the loot of an existing loot table into a custom chest? Just use LootTable#fillInventory
    Are you trying to create your own custom loot tables?

    The existing vanilla loot tables are listed in the enum LootTables.
    • Useful Useful x 1
  3. Huh, I never came across those somehow. My plan is to have the default loot tables for chests but have them be customizable to add extra or remove items. To then be awarded to players. That certainly makes the first part of that much easier, thank you
  4. Loot tables can already be customized, that‘s what (among other things) resource packs do
  5. I assume you mean data packs. But that's not what I'm doing, as I said in my other message I am using these as awards for players. So it needs to be a whole ton more customizable. the idea is that you can write a bit of code to add items to what would normally be in a loot chest and then get that as a list of ItemStacks to give to a player in some way. Plus I want it to be as simple as installing a plugin rather than having a plugin and a data pack to install.
  6. “Codify” lmao no!

    so you want something along the lines of
    Code (Java):
    ChestPopulator.populate(chest, lootTable);
  7. Not quite. I'm making this more as a challenge to myself to see what I can do. I'm trying to make a plugin that randomizes block drops like in some of the random UHC things. So for that I wanted to be able to drop items as if the player broke a loot chest. But I'm also thinking where else I could use it so I want to be able to add and remove items. My initial idea was to run the probabilities for each chest based on those gamepedia numbers. But that's before I was told about the pre-existing loot table stuff.
    I'll play around with stuff tomorrow but I'm pretty sure I've got all I need.