Minecraft Data Packs / Tool

Kai's 'Structure to Loot Table' Tool

  • check_circle Loot Tables
  • check_circle Structures
  • 1,454 views, 1 today
  • 33 downloads, 0 today
  • 8
  • 5
kaimedina's Avatar kaimedina
Level 36 : Artisan Engineer
18


Purpose


This code allows you to put in a structure block .nbt file, and receive a loot table using all the blocks present in the build (and optionally items within chests & barrels in said build, including their enchantments, names, and lore). The likelihood of receiving each block in your loot table is tied to how often that block appears. If cobblestone appears in the build 4 times, and dirt appears 8 times, then you are twice as likely to get a dirt block in the table as compared to cobblestone.

It's niche, but it works.

I created this code for a local server with friends. We reset the server and will be playing in a flooded environment. I want them to find remnants of their builds in the past world through both structures and mining/fishing/obtaining blocks used. Additionally using other tools like misode's loot table generator lets me name certain things and add a little bit of lore.

The purpose of this is to allow for items used in old builds to be rediscovered within datapacks, especially in environments with limited block obtainment. Floods, Fishing, Abandoned Structure Chests, skyblock moments, Popping up in dust storms being thrown by the wind, etc etc etc.

If you update the code or use it in anything, follow the attribution at the bottom of this page. Also shoot me a message on twitter @not_kia_, I'd love to hear about it.

VERSION: This code works in 1.19-1.20+. In theory it should work in higher and slightly lower versions, as long as loot table code formatting has not changed.

How To Use


Before Running this code:
Please go to File > Save a copy in your drive. This makes a duplicate of this code in your google drive. Otherwise everyone would be on this same bit of code, getting in eachother's way. Make sure you run the code in your copy.

Run the code:
Hit Runtime > Run All or hit the play button on the top left of the code below.

Use the code:
Scroll to the bottom of the page and there should be a prompt button to upload a file. Upload one .nbt minecraft structure file here (found in your .minecraft save's generated folder). It will be uploaded locally on google colab, which means it's hosted temporarily by google. It's not filling up my files and as soon as you exit the page, it's gone. Water, Lava, and Air blocks will be removed from your loot table automatically, but lava_buckets and water_buckets should stay if they're in a chest.

When prompted about rarity, this is how likely (scale of 0 to 1) you will find loot at all. If my rarity is .25, then if I have four chests associated with the loot table, only one will likely have loot.

If your structure has chests, and if those chests have items in them, you will have the option (y/n) to include those items in your loot table. They will be treated the same as blocks.

It might take a second to run through, but when it's ready then you can copy your results. Be careful not to accidentally copy any of the confirmations of your file upload, just the code starting at '{'. Doing ctrl + a will select the extra bits at the top.

If your file output is too long (not unusual, especially with files containing chests), a text file is outputed in the folder icon on the left side of your screen labled output.txt. Download that to access the full output

Finally, Finish your code by placing it here: https://misode.github.io/loot-table/ (note chest blocks do appear in code but are not visible in the site's loot table graphic). This will test that it's working, and let you modify anything you want to change.

Improve your results:

If you want to use a larger build, like I am using this for, I suggest downloading a mod that breaks the size limitations on structure blocks. Remember to always backup worlds before using mods.

You might want to remove certain blocks. This thing ignores air but it won't ignore all that dirt and stone surrounding your build. Visit misode's site to paste in your loot table and test/modify it: https://misode.github.io/loot-table/

By editing the rolls (see picture below) on that site, you can increase the loot from just one item to many. The site lets you change plenty else about the items too.


Kai's 'Structure to Loot Table' Tool Minecraft Data Pack


Kai's 'Structure to Loot Table' Tool Minecraft Data Pack

Attribution: This code is Attribution 4.0 International (CC BY 4.0), you are free to share and adapt this work commercially or non-commercially as long as proper credit is attributed to Kai Medina in a publicly accessible way (not hidden in code)

Flaws: The code does not currently carry over the damage done to tools, or any other item data aside from id, enchantment, name, and lore.

Other Tools of mine:

Clone Large Structures (CLS) https://www.planetminecraft.com/data-pack/clone-large-structures-cls-i-found-no-viable-way-to-do-this-in-minecraft-or-other-programs-so-a-friend-and-i-made-one/

Concept/Prototype/Tutorial: Reward Structure Repair https://www.planetminecraft.com/data-pack/concept-prototype-tutorial-reward-structure-repair/

See my profile for other datapacks.
CompatibilityMinecraft 1.19
toMinecraft 1.20
Tags

3 Update Logs

Update #3: Larger Files & Barrel Fix : by kaimedina 05/12/2023 11:00:25 amMay 12th, 2023

Code now exports its output as a .txt file within your google drive if it's too long to be stored in google collab, and checks for barrel items now too.

Edit: Removed cave_air and a few other common non-itemable-blocks. Didn't get all of them but they don't harm the output, and the loot table generator site shows any that might appear weird. (ex: pumpkin stalk, rose in pot, etc)
LOAD MORE LOGS

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome