API reference Obsidian.API.World.Features.Trees
FoliagePlacer class
Places a tree's leaves around each FoliageAttachment, like vanilla's FoliagePlacer. Plugins add types with RegisterWorldgenType<FoliagePlacer, T>.
public abstract class FoliagePlacer
In Obsidian.API.
Constructors
protected FoliagePlacer();Properties
public required IIntProvider Offset { get; init; }public required IIntProvider Radius { get; init; }public string Type { get; init; }Methods
CreateFoliage(TreeContext, int, FoliageAttachment, int, int)
public void CreateFoliage(TreeContext tree, int freeTreeHeight, FoliageAttachment attachment, int foliageHeight, int foliageRadius);Places foliage at one attachment; samples FoliagePlacer.Offset once per call, like vanilla.
protected abstract void CreateFoliage(TreeContext tree, int freeTreeHeight, FoliageAttachment attachment, int foliageHeight, int foliageRadius, int offset);GetFoliageHeight(IRandomSource, int)
public abstract int GetFoliageHeight(IRandomSource random, int treeHeight);Height of the foliage, used to compute the trunk length before the foliage radius is sampled.
public virtual int GetFoliageRadius(IRandomSource random, int trunkHeight);PlaceLeavesRow(TreeContext, Vector, int, int, bool)
protected void PlaceLeavesRow(TreeContext tree, Vector center, int radius, int y, bool doubleTrunk);Places a square row of leaves of radius at y blocks above center.
PlaceLeavesRowWithHangingLeavesBelow(TreeContext, Vector, int, int, bool, float, float)
protected void PlaceLeavesRowWithHangingLeavesBelow(TreeContext tree, Vector center, int radius, int y, bool doubleTrunk, float hangingLeavesChance, float hangingLeavesExtensionChance);Places a row like FoliagePlacer.PlaceLeavesRow, then randomly hangs one or two leaves below its outer edge (used by cherry trees).
ShouldSkipLocation(IRandomSource, int, int, int, int, bool)
protected abstract bool ShouldSkipLocation(IRandomSource random, int dx, int y, int dz, int radius, bool doubleTrunk);Whether to leave out the leaf at (dx, y, dz) of a row of radius; dx/dz are absolute distances from the trunk.
ShouldSkipLocationSigned(IRandomSource, int, int, int, int, bool)
protected virtual bool ShouldSkipLocationSigned(IRandomSource random, int dx, int y, int dz, int radius, bool doubleTrunk);Converts signed offsets to distances (measured from the nearer trunk column of a 2x2 trunk).
TryPlaceLeaf(TreeContext, Vector)
protected static bool TryPlaceLeaf(TreeContext tree, Vector position);Places a leaf unless the position holds persistent leaves or isn't a valid tree position (air or #replaceable_by_trees); leaves that can be waterlogged are waterlogged in water source blocks.