random_variation
Last updated
Last updated
There are many structures that can also have variant materials. E.g. the Watchtower is built from spruce, but a dark oak watchtower could be naturally generated as a new, fresh alternative. Shrines' Random variation feature exchanges the materials of its builds on every placement. You can see a Balloon in white, in red, purple, green etc. Since 3.x.x you're also able to fully configure random variation through datapacks.
This paragraphs requires some basic knowledge about minecraft datapacks
Let's first talk about how random variation works. Here is what we want to achieve with it:
Imagine the [] being one block each. We will use 2-dimensional only.
Imagine you want this structure:
to look like this one:
but because you're lazy, you only want to write
In fact, random variation allows you to do that. You don't even need to generate new structure files in advance, the mod will do that at generation time. You still need to help Shrines a bit. It doesn't know which blocks belong to which "material".
A "material" is a set of blocks assigned to an "element id". For example the acacia material looks like this:
and the oak material look like this:
(In fact, both materials contain more blocks, but they aren't important for this article)
You probably noticed already the common ground of both materials. The mod will go over each block of the structure and checks which block of the material it matches and takes the assigned id. Next, it will look at the assigned materials and search for the id and take the block. The taken block will be placed then
That's how it works in a bit simplified. To make random variation work properly, you need at least 3 files. 1 "random variation config" file and 2 "random variation material" file. You can add those files though datapacks. Just as minecrafts datapack entries, they have to be placed into a certain directory. Ass directories are relative to the datapack's namespace.
Path for random variation config: shrines/random_variation/config
Path for random variation material: shrines/random_variation/material
Here is an example config file: https://github.com/Silverminer007/Shrines/blob/1.18.2%2B-4.x.x/src/main/resources/data/shrines/shrines/random_variation/config/azalea_pavilion.json
Here is an example material file: https://github.com/Silverminer007/Shrines/blob/1.18.2%2B-4.x.x/src/main/resources/data/shrines/shrines/random_variation/material/acacia.json
There are 53 default material files that you can use, so our example could easily be implemented in a config file:
Important: The name of your config file must be the same as the configured structure feature. Same for namespace
If you have questions or concerns feel free to ask on discord: https://discord.gg/8pUpWCEUe2