API reference Obsidian.API.World.Features.Trees
TrunkPlacer class
Places a tree's trunk and reports where foliage attaches, like vanilla's TrunkPlacer. Plugins add types with RegisterWorldgenType<TrunkPlacer, T>.
public abstract class TrunkPlacer
In Obsidian.API.
Constructors
protected TrunkPlacer();Properties
public required int BaseHeight { get; init; }public required int HeightRandA { get; init; }public required int HeightRandB { get; init; }public string Type { get; init; }Methods
protected static string AxisOf(BlockFace face);GetTreeHeight(IRandomSource)
public int GetTreeHeight(IRandomSource random);Vanilla getTreeHeight: base_height + rand(0..a) + rand(0..b).
IsFree(IWorldGenLevel, Vector)
public bool IsFree(IWorldGenLevel level, Vector position);Whether a trunk may grow through the position: TrunkPlacer.ValidTreePos or an existing log.
PlaceLog(TreeContext, Vector, Func<IBlock, IBlock>)
protected bool PlaceLog(TreeContext tree, Vector position, Func<IBlock, IBlock> transform = null);Places a trunk block if TrunkPlacer.ValidTreePos, optionally transforming the provided state (e.g. log axis).
protected void PlaceLogIfFree(TreeContext tree, Vector position);PlaceTrunk(TreeContext, int, Vector)
public abstract List<FoliageAttachment> PlaceTrunk(TreeContext tree, int freeTreeHeight, Vector origin);Places the trunk starting at origin and returns the foliage attachment points.
Parameters
freeTreeHeight- Height actually available, possibly clipped below the sampled tree height.
SetDirtAt(TreeContext, Vector)
protected static void SetDirtAt(TreeContext tree, Vector position);Vanilla setDirtAt: replaces the block with the dirt provider unless it's already dirt (forced by force_dirt).
ValidTreePos(IWorldGenLevel, Vector)
protected virtual bool ValidTreePos(IWorldGenLevel level, Vector position);Vanilla TreeFeature.validTreePos: air or #replaceable_by_trees.
WithAxis(string)
protected static Func<IBlock, IBlock> WithAxis(string axis);Vanilla trySetValue(RotatedPillarBlock.AXIS, axis).