-
Notifications
You must be signed in to change notification settings - Fork 0
Data Driven Crates
Crates are data-driven and can be added through a Data Pack and a Resource Pack! This page will only contain how to make the contents of a data pack that interacts with the mod, other things like data pack creation will not be mentioned here outside of resource links.
First of all, create a basic working data pack. (Minecraft Wiki - Creating a data pack)
Once that's done, inside of the data pack, create a new .json file under the path: <YourDataPack>/data/svcrates/crates/<your_file>.json
The .json file structure for a custom crate is like this:
{
"<crate>": ["<loot_table_id>", ["<biome id or biome tag>"], ["<texture1>", "<texture2>"], <weight>, ["<dimension>"]]
}Multiple JSON lines can be added to register various crates, multiple files also works but it is very redundant to do so.
Example:
{
"magic": ["chests/village/village_cartographer", ["#c:is_magical", "minecraft:dark_forest"], ["magic_crate_side", "magic_crate_top"], 15, ["minecraft:overworld"],
}The values shown above cannot be anything, so here's a breakdown on how they work:
<crate> = String, cannot contain spaces, special characters aside of _ and - and must be lowercase, make sure you're not adding a crate that already exists, or else there is a chance this or the other crate will end up being overwritten. These rules apply to every other value. Eg: "magic":
<loot_table_id> = String, takes in a loot table id, can be vanilla, modded or your own one, just make sure that the loot table you're referencing actually exists in your world. Eg: "chests/village/village_cartographer"
Loot Table Generator - This site lets you generate a usable loot table for your data pack.
Minecraft Wiki - Loot Table
["<biome id or biome tag>"] = Array[String], a list of biomes or biome tags that this crate can be fished up in. Eg. ["#c:is_magical", "minecraft:dark_forest"]. All biome tags must start with a # <--
If the value of the list is "*" that means this crate will be able to spawn in any biome! Do not add other biomes or biome tags to this list if it is set to ["*"].
["<texture1>", "<texture2>"] = Array[String], a list of image names that will be in the resource pack, will explain how to add them in the Resource Pack section. For now, here's how this works:
The list must contain at least two string values, Eg: ["magic_crate_side", "magic_crate_top"]. Just like the example, the first value will be the sides of the crate, while the second value is going to be the top and bottom sides of it.
In case you want more customization for each side, you can input six string values, Eg: ["trial_crate_bottom", "trial_crate_top", "trial_crate_front", "trial_crate_side", "trial_crate_side", "trial_crate_side"].
Each value being: [DOWN, UP, NORTH, SOUTH, WEST, EAST]
It is very important that the values are either two or six, otherwise the textures won't work.
Note: As of right now the crates do not rotate when placed, this is a feature that will be added as a future update.
<weight> = Integer, whole number, defines how rare this crate is, a good point of reference is a basic wooden crate, it can spawn in every biome and its weight is equals to 20, currently the most common crate, so if you want something rarer, go for a number below 20, like 15, 10. Do note that since this is a weighted rarity chance, the more crates you have, the rarer all of them become.
For a more comprehensive explanation on how weighted selections work, see this article: How to: Weighted Random Selections.
You can see a list of all of the mod's base crates here: Crate List
["<dimension>"] = Array[String], a simple list of dimensions, eg: ["minecraft:overworld"]. Can be set to ["*"] to allow any.
"
This is everything for the data pack side of things! You can now put this inside of the datapacks directory of your world. Only thing left is to make a Resource Pack containing the textures.
This should be a lot simpler, you'll need a Resource Pack. (Minecraft Wiki - Creating a resource pack)
This is where the crate textures will go, drop your .png files in this directory of your custom resource pack:
<YourResourcePack>/assets/svcrates/textures/block/<my_texture>.png
The texture must be 16x16 and a .png!. And the file name here should match the one you put into your .json file for the data pack, just without the .png at the end.
Now, language file, create a .json file at the following path:
<YourResourcePack>/assets/svcrates/lang/en_us.json (This is for specifically English)
Inside of it type the following:
{
"item.svcrates.<crate>": "My Crate Name"
}<crate> being replaced with the id of the crate from your data pack! You can add new lines for more crate language files.
Once that is done, you can put your newly created resource pack inside of your resourcepacks folder on your minecraft instance, and once that is there open the game, go to your Options then Resource Packs and make sure it is enabled, otherwise it won't work either.
Done! This should do the trick, if there are any issues regarding this feature make sure to go to our Issues tab and report any crashes or anomalies you encounter. And if you need help, make a post on the Discussions tab.