Skip to content

Tree Packs: World Generation

Max Hyper edited this page Feb 5, 2024 · 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": The identifying name of a biome
  • "tag": A biome tag
    • 1.19.2 and above only
  • "type": A biome type from forge's biome dictionary (forge biome classification)
    • Removed in version 1.19 and above, replaced by "tag".
  • "category": A biome category (vanilla biome classification)
    • Removed in version 1.19 and above, replaced by "tag".

The array elements allow for multiple values that apply together with as if an AND was used.

  • "names": An array of biome names
  • "tags": An array of biome tags
    • 1.19.2 and above only
  • "types": An array of biome types
    • Removed in version 1.19 and above, replaced by "tags".

However these array elements apply together as if an OR was used.

  • "names_or": An array of biome names

Not operator

All of these names, types, categories and tags can be reversed by using "!" (as not).

For example:

  • "tag": "!#is_sandy" any biome that is not sandy
  • "names": ["!minecraft:plains", "!minecraft:forest"] Every biome except forest and plains.

Binary Operators

All of these properties can be included within OR, AND, and NOT array objects, to fully combine them in binary operation.

For example:

"select": {
  "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.

However the default behavior of "select" allows for using a list which behaves exactly like the AND operator. That means that in this case using the AND operator is redundant and it can be simplified.

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

Regular Expresions

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

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.

Debugging

When working on world generation, it might be useful to enable the debug feature to find what issues are preventing your trees from generating how you want.

To do this, find the serverconfig file located in saves/[your world]/serverconfig/dynamictrees-server.toml and set debug=true at the bottom of the file.

Now, when exploring the world you will find colored concrete blocks that show the Poisson Discs. image

The color of the block in the center of the disc will show you WHY a tree failed to generate there.

  • BLUE: Failed Chance. The probability that a tree generates was defined as less than 1 and thus some trees do not generate.
  • BROWN: Failed Soil. The tree that attempted to generate there cannot be planted on the block that was in that spot.
  • YELLOW: Unhandled Biome. No worldgen file defines what to do with this biome, so no trees generate.
  • RED: Failed Generation. An error occurred during generation, usually caused by a missing jocode.
  • PURPLE: No Soil. This tree attempted to generate over the void.
  • BLACK: No Tree. The specified species is invalid, check for typos.

The following colors should never show up as they signify a successful generation. If you do see them, something broke.

  • WHITE: Generated. The tree generated successfully.
  • GRAY: Already Generated. A tree was already there. (Rooty cave trees generate first)