Repository navigation
API Worldgen Trees
Lua API / World generation / Trees
Trees are reusable atomic features. They can use a vanilla-style adapter, bounded procedural geometry, or one of several authored local structures. Schedule the returned reference through an ordinary placement or place it directly from an authoritative callback.
Compiles a tree and returns a feature reference. Keys normalize to namespace:tree/path; get returns a reference or
nil, and getRequired raises an error when absent.
local silverwood = betamoon.worldgen.trees:add {
key = "mymod:silverwood",
trunk = {
block = silverLog,
height = { min = 6, max = 10 },
radius = 1,
bend = 0.12
},
branches = {
start = 0.55,
count = { min = 3, max = 7 },
length = { min = 2, max = 4 },
upwardBias = 0.35
},
canopy = {
block = silverLeaves,
shape = "clustered_sphere",
radius = { min = 2, max = 4 },
density = 0.82
},
ground = { 2, 3 },
replace = { 0, 18 }
}| Field | Default / range |
|---|---|
key |
Required stable tree key. |
trunk.block |
Required block. |
trunk.metadata |
0; accepts 0–15. |
trunk.height |
Required integer or range, 1–24. |
trunk.radius |
1; accepts 1–2. |
trunk.bend |
0; accepts 0–1. |
branches.start |
0.55; accepts 0.1–0.95 as the trunk-height fraction at which branching starts. |
branches.count |
Required when branches is supplied; integer/range 0–16. |
branches.length |
Required when branches is supplied; integer/range 1–12. |
branches.upwardBias |
0.25; accepts 0–1. |
canopy.block |
Required leaf block. |
canopy.metadata |
0; accepts 0–15. |
canopy.shape |
sphere; also layered_disk, cone, or clustered_sphere. |
canopy.radius |
Required integer/range 1–8. |
canopy.density |
1; accepts 0.05–1. |
ground |
Grass and dirt. |
replace |
Air and leaves. |
Shape guide:
-
spherecreates a rounded continuous crown; -
layered_diskcreates stacked flat foliage layers like a classic small tree; -
conenarrows upward for spruce-like crowns; -
clustered_spherecreates several overlapping rounded foliage clusters.
BetaMoon plans the trunk, branches, and canopy together. If a required cell is blocked or another validation fails, the entire tree is rejected before any block changes.
local paleTree = betamoon.worldgen.trees:add {
key = "mymod:pale_tree",
generator = "normal",
trunk = paleLog,
leaves = paleLeaves,
trunkMetadata = 0,
leavesMetadata = 0,
ground = { 2, 3 }
}generator is normal, big, or taiga. The adapter supplies bounded height, canopy, and branch defaults;
optional trunk, leaves, and metadata fields replace its materials without changing global Minecraft blocks.
ground and replace use the same defaults as procedural trees.
local ancientTree = betamoon.worldgen.trees:add {
key = "mymod:ancient_tree",
templates = {
{ structure = "mymod:ancient_tree_a", weight = 3 },
{ structure = "mymod:ancient_tree_b", weight = 1 }
},
rotation = "random_horizontal",
mirror = "none",
ground = { enchantedSoil }
}| Field | Default / behavior |
|---|---|
templates |
Required nonempty weighted list. Every structure must be a local structure reference or key. |
weight |
1; positive relative weight. |
rotation |
random_horizontal; accepts the ordinary local-structure rotations. |
mirror |
none; accepts the ordinary local-structure mirrors. |
ground |
Grass and dirt. |
One template is selected per tree placement. An ore, patch, sequence, or other generic feature is rejected where a structure template is required. A direct placement's explicit rotation or mirror overrides these tree defaults.
References expose getKey() and all ordinary feature preview/place behavior.
Examples: simple tree placement and complete modular worldgen pack.
- Installation
- Install scripts
- Getting started
- VS Code and LuaLS
- Examples
- Reload and compatibility
- Troubleshooting
- Changelog
Scripts and shared values
- Script lifecycle
- Packaged Lua mods
- Modules
- References and stacks
- Queries
- Overrides
- Minecraft constants
- Chat and positions
- Structured data
- Script configuration
- Particles
Blocks and items
- Multiblocks
- Blocks
- Block state and placement
- Block shapes and rendering
- Block callbacks
- Block ticks and redstone
- Items
- Fluids
- Item callbacks
- Tools and armor
- Materials
- Textures
Entities
- Entities
- Entity access and movement
- Entity lifecycle and data
- Entity health and loot
- Entity inventories and relationships
- Projectiles and pickups
- Entity presentation and sounds
- Living entities and AI
- Entity parts and sensors
Assets and audio
- Assets
- Models and animations
- Built-in Minecraft models
- Model appearances
- Blockbench workflow
- Audio
- Texture-pack overrides
Events and world actions
World generation
World systems
Inventories and screens
Recipes