Skip to content

Tree Packs: World Generation

supermassimo edited this page Apr 10, 2023 · 13 revisions

What is it

The world_gen folder should contain two files. default.json handles the generation of dynamic trees for each biome in the terrain, while feature_cancellers.json handles applying cancellers, which disable existing generation of non-dynamic features such as trees, mushrooms, nether fungi, or similar.

Biome Selectors

A biome selector is a boolean operand that determines which biomes the following generation/cancellation will be applied to. The simplest selector uses the "name" element to just select a specific biome by name.

A basic understanding of binary logic is heavily recommended to use the biome selectors to their fullest potential.

The basic elements for a selector are the following, by default when applied together they will behave like with an AND operation:

  • "name": A biome name
  • "type": A biome type from forge's biome dictionary (forge's biome tags)
  • "category": A biome category (vanilla's version of biome tags) The array elements allow for multiple values that apply together with as if an AND was used.
  • "tag": A biome tag
  • "names": An array of biome names
  • "types": An array of biome types
  • "tags": An array of biome tags However these array elements apply together as if an OR was used.
  • "names_or": An array of biome names
All of these names, types and categories can be reversed by using "!" (as not).

For example:

  • "type": "!sandy" any biome that is not of sandy type
  • "names": ["!minecraft:plains", "!minecraft:forest"] Every biome except forest and plains.
Biome names can use regular expressions.

For example:

  • "minecraft:.*" will select all minecraft biomes
  • ".*hills.*" will select any biome with "hills" in the name
  • "!.*wooded.*" will select every biome except those with "wooded" in the name
All of these properties can be included within OR, AND, and NOT array objects, to fully combine them in binary operation.

For example:

"AND": [{"OR": [{"type": "cold"}, {"type": "snowy"}, {"type": "coniferous"}]},{"types": ["overworld", "!spooky", "!rare"]}]

This selects biomes that are cold, snowy OR coniferous, AND that are of type overworld but NOT spooky AND NOT rare

Species Selectors

The species selector defines the species that will be selected to generate in a structure similar to that of a weighted list. There are two parameters used here. random and method.

To create or replace a pool of species

In this instance the "method" parameter is optional as this is the default behavior.

  • "random": An object where each species has a number that represents its weight in the pool.
  • "method": Must be set to replace or not included altogether.

For example:

"species": {
        "random": {
          "dynamictreesplus:pillar_cactus": 6,
          "dynamictreesplus:pipe_cactus": 1
        }
      }

Means that pillar cacti are 6 times more likely than pipe cacti to be selected.

The selector can also use "static" instead of "random" with a single species name, which behaves just like using the name directly.

"species": {
        "static": "oak"
      }

is equivalent to:

"species": "oak"
To add to an existing pool of species

To add to an existing pool the "method" parameter must be splice_before or splice_after. and a "..." element MUST be added to the random object.

  • "random": An object where each species has a number that represents its weight in the pool. "..." is the weight of the rest of the existing pool.
  • "method": splice_before or splice_after.

For example:

"species" : {
        "method" : "splice_before",
        "random" : {
          "dtautumnity:maple" : 1,
          "..." : 10
        }
      }

This selector will add a 1/10 chance for the a tree to be maple to a selected existing pool of generation. The other 9/10 trees will be whatever was previously set up to generate.

Density Functions

//to-do

Cancellers

Feature cancellers detect and cancel features that generate in some specific way. Some mods take their own approach to generation, and thus a custom canceller might be needed to successfully remove the features from the world.

However these should cover the cases where vanilla features are used, or ones that imitate them in implementation.

By default, the cancellers provided by Dynamic Trees are {tree, rooted_tree, mushroom, fungus}. More can be added by other addons. Dynamic Trees Plus adds {dynamictreesplus:cactus} to cancel cacti.

default.json

This file contains an array of elements, each handling a case of biomes where Dynamic Trees will be generated.

  • "select": The biomes selected to apply these cancellers to. Must be a valid biome selector
  • "apply": An object, or an array of objects with the properties species, density and chance.
    • "species": A single species id or a species selector.
    • "density": A number or a function to configure the radii of the trees that generate. A higher density means smaller trees more packed together, a lower density produces larger trees spaced apart more.
    • "chance": A number between 0 and 1 that defines the chance for a tree to generate on each valid spot.

It is important to note that depending on how the species selector is set up, the generation could be either completely replaced OR the new trees can be added to the existing pool.

feature_cancellers.json

This file contains an array of elements, each handling a case where cancellers should be applied. Every element must have these properties:

  • "select": The biomes selected to apply these cancellers to. Must be a valid biome selector.
  • "cancellers": An object, or an array of objects with the properties type and namespace.
    • "type": The canceller itself, must be an option from an existing registered canceller.
    • "namespace": The namespace of the feature, vanilla features use minecraft.