Skip to content

Mod Integration

Snissac edited this page Nov 3, 2026 · 1 revision

Mod Integration

Most tree mods only need Block Tags. Use the Java API when your trees don't work like vanilla ones, for example with custom branch blocks.

This API is not stable yet. It's built for the Dynamic Trees add-on and can change between versions, so tell your users which version you tested.

Register a module

Implement com.snissac.sabletrees.fell.TreeMods.TreeMod and register it once, when your mod starts:

TreeMods.register(new MyTreeMod());

Depend on Sable Trees as an optional or required mod, and only load this class when it's installed.

Required methods

Method What it does
cut(level, pos, state) The cutting rule for this block, or null if it isn't yours
primitiveLog(state) The regular log behind this block, for wood type and stump drops, or null
breakInBody(level, pos, state, player) A player broke your block inside a fallen tree; return true if you handled it
topple(level, base, hit, direction, fallingHeight) A falling tree hit your block; return true if you handled it, false for the normal domino
dissolveDebris(level, body) A settled body may be just debris of yours; remove it and return true

cut returns one of TreeMods.Cut:

Value Meaning
DEFAULT The normal rule: notch, back cut, pruning
INSTANT_NOTCH One hit notches and fells toward the player, for thin trunks
THICK The hit notches a whole layer, from thickLayer
PRUNE A branch: break it, and what lost its support falls, through prune

Optional methods

Method Default What it does
prune(level, pos, state, player) false Handles PRUNE
thickLayer(level, pos, state) null The blocks of the layer for THICK
isTrunkPart(state) false A block that belongs to the trunk without being in #minecraft:logs
bodyDrops(level, pos, state) null What your block drops when a fallen tree breaks; also used by the saw in SINGLE mode
afterRemoved(level, removed) nothing Trunk blocks just left the world; check what they were holding
dissolveTiny(level, blocks, dropAt) false Remove a piece too small to be worth a physics body
notchBase(original) null Your own notched block instead of the core's
rottenLogBase(source) null Your own rotten log instead of the core's

Example

The Dynamic Trees add-on is the full use of this API.

Clone this wiki locally