Skip to content

Adding trees with a datapack

Complicated Trees breeds the trees that already exist. It adds no wood blocks of its own, so a tree from another mod only needs a small datapack that tells Complicated Trees which blocks belong to it. No code and no new art is needed.

A datapack can add a species, a cross that produces it, and new genes. This page walks through one modded tree from start to finish. Both example packs can be downloaded at the end.

What a datapack needs

Piece Where it goes Needed
Species data/<namespace>/complicated_trees/species/<name>.json Yes
Cross data/<namespace>/complicated_trees/breeding/<name>.json Only if the tree should come from breeding
Species group data/<namespace>/complicated_trees/species_tags/<name>.json No
Allele data/<namespace>/complicated_trees/alleles/<name>.json No

The species id is <namespace>/<file name>. The file data/orchard/complicated_trees/species/maple.json makes the species orchard:maple. The id does not depend on the other mod's ids.

Step by step: a modded tree

The example adds Gloamwood from Slowlight.

1. Make the pack folder

gloamwood/
  pack.mcmeta
  data/gloam_example/complicated_trees/species/gloamwood.json
  data/gloam_example/complicated_trees/breeding/gloamwood.json

pack.mcmeta on 26.2:

{"pack": {"description": "Gloamwood for Complicated Trees", "min_format": [88, 0], "max_format": [107, 1]}}

Other versions use "pack_format": 15 on 1.20.1, "pack_format": 48 on 1.21.1, and "min_format": [84, 0], "max_format": [101, 1] on 26.1.2.

2. Find the tree's block ids

Three ids are needed.

  • The sapling item. Hold it and run /data get entity @s SelectedItem, or read it in JEI. The id looks like slowlight:gloamwood_sapling.
  • The leaves. Look at them and press F3. The id shows under "Targeted Block".
  • Every log block of the trunk. Include the plain log and the wood block (all bark). Add the stripped versions if the tree should still count after stripping.

Selectors accept exact ids, or a block tag with a leading #, for example #slowlight:gloamwood_logs.

3. Write the species

data/gloam_example/complicated_trees/species/gloamwood.json:

{
  "schema_version": 1,
  "requires_mods": ["slowlight"],
  "display_name": "Gloamwood",
  "source_sapling": "slowlight:gloamwood_sapling",
  "recognition": {
    "leaves": ["slowlight:gloamwood_leaves"],
    "logs": [
      "slowlight:gloamwood_log",
      "slowlight:gloamwood_wood",
      "slowlight:stripped_gloamwood_log",
      "slowlight:stripped_gloamwood_wood"
    ]
  },
  "growth": {"type": "complicated_trees:native_sapling"},
  "default_genes": {
    "complicated_trees:fertility": "complicated_trees:fertile",
    "complicated_trees:maturation": "complicated_trees:quick"
  }
}
Field Meaning
schema_version Always 1.
requires_mods Mod ids that must be installed. If one is missing the species and every cross that uses it are skipped, and the pack still loads.
source_sapling The other mod's sapling. Genetic stock of this species grows the way that sapling grows.
recognition The leaf and log blocks that count as this species. Anything the tree grows must be listed here.
growth How the tree is built. See growth drivers.
default_genes Genes a fresh stock item starts with. Optional.
soils Blocks the sapling can be planted on. Optional. The default is dirt, grass, podzol, mycelium, moss blocks and farmland.

The base mod's own sapling needs no change. It keeps working as usual.

4. Write the cross (optional)

data/gloam_example/complicated_trees/breeding/gloamwood.json:

{
  "schema_version": 1,
  "parents": ["complicated_trees:oak", "complicated_trees:birch"],
  "result": "gloam_example:gloamwood",
  "chance": 0.1,
  "priority": 0,
  "conditions": [{"type": "dimension", "value": "minecraft:overworld"}]
}

Parent order does not matter. Crosses that can happen together must have chances that add up to no more than 1. The built-in oak and birch cross already takes 15%, so this one takes 10% more. Conditions are optional and all must pass. The supported conditions are listed under Conditions.

Without a cross, the species can still be used: /trees stock gloam_example:gloamwood gives Genetic stock in Creative.

5. Install and test

  1. Zip the pack so that pack.mcmeta is at the top of the zip, or leave it as a folder.
  2. Put it in the world's datapacks folder.
  3. Run /reload.
  4. Run /trees species. gloam_example:gloamwood should be listed.
  5. Run /trees crosses. The new cross should be listed.
  6. In Creative, run /trees stock gloam_example:gloamwood, plant the sapling and let it grow.

Without the other mod installed, the species is skipped and the log says "Skipping optional tree cross". Fix any error the log reports and run /reload again. A bad update is rejected and the previous definitions stay active.

Growth drivers

Driver Use
complicated_trees:native_sapling Uses the source sapling's own bone meal growth. Works for trees that have one sapling.
complicated_trees:configured_feature Builds the tree from a world generation feature. Add "feature": "<namespace>:<feature>".

Some trees from other mods have their own growth code that uses block entities or side effects. Plant a test tree of every species and check the result. Trees with several saplings are not supported.

The feature form:

"growth": {"type": "complicated_trees:configured_feature", "feature": "slowlight:gloamwood"}

The feature must only place blocks listed under recognition. It gives no control over height or width.

Conditions

A cross can carry conditions. Each is an object with a type and a value, for example {"type": "biome", "value": "minecraft:forest"}. The types in the released 0.1.0 jars are dimension, biome, biome_tag, nearby_block, nearby_block_tag and working_housing. working_housing takes no value. Tag values leave out the #. Later builds add more types.

Reloading and existing worlds

Existing stock keeps its species when a pack is removed and works again when the pack is put back with the same ids. Do not rename ids in a pack that players already use.

Differences between versions

Complicated Trees reads the same files on every version. The folders species, breeding, alleles and species_tags under data/<namespace>/complicated_trees/, the JSON fields and the commands do not change. Only the pack metadata differs, and so do the folder names of Minecraft's own data when a pack adds them.

Minecraft Loader pack.mcmeta Vanilla tag folder Example packs tested
1.20.1 Forge "pack_format": 15 tags/blocks Yes
1.21.1 NeoForge "pack_format": 48 tags/block Yes
26.1.2 NeoForge "min_format": [84, 0], "max_format": [101, 1] tags/block Yes
26.2 NeoForge "min_format": [88, 0], "max_format": [107, 1] tags/block Yes

A block tag used as a selector, such as #slowlight:gloamwood_logs, comes from the other mod's own data, so the tag must exist on that Minecraft version. The block ids used by the examples are the same on all four versions of Slowlight. Species and cross ids carry no version.

Example packs

Both packs add Gloamwood and need Slowlight 0.9.5. They load on Minecraft 1.20.1, 1.21.1, 26.1.2 and 26.2 with Complicated Trees and Complicated Bees installed, and the species and cross appear in the commands above. Without Slowlight they are skipped. Pick the zip that matches the Minecraft version.

Pack What it shows 1.20.1 1.21.1 26.1.2 26.2
Gloamwood, native sapling The steps on this page: one species and one cross. zip zip zip zip
Gloamwood, feature The same tree built from a world generation feature. zip zip zip zip

To adapt a pack, change requires_mods, the namespace, the sapling id and the leaf and log ids.