Skip to content

API reference Obsidian.API.World.Structures

CustomStructure class

A structure type a plugin adds in code, like a NeoForge mod's structure type: structure files name it in their type. Register it with RegisterWorldgenType<CustomStructure, T>.

public abstract class CustomStructure

In Obsidian.API.

Remarks

Obsidian reads a structure's common fields (biomes, spawn_overrides, step and terrain_adaptation) itself, checks the biome at the start, and places the pieces; the file's other keys set the type's properties, read like a feature type's.

Instances come from structure files and are shared between threads, so keep them stateless. Starts aren't saved with their pieces: they're made again from the seed when a chunk needs them, also after a restart, so a start must depend only on its context.

Constructors

protected CustomStructure();

Methods

AddPieces(StructureStartContext, Vector, ICollection<CustomStructurePiece>)

public abstract void AddPieces(StructureStartContext context, Vector start, ICollection<CustomStructurePiece> pieces);

Adds the structure's pieces, once it starts at start. A structure without pieces doesn't start. Called with the same context, so its random goes on from CustomStructure.FindStart's.

FindStart(StructureStartContext)

public abstract Vector? FindStart(StructureStartContext context);

Where the structure starts in the context's chunk, or null when it doesn't start there. The structure only starts when the biome there is one of its biomes.

On this page