// generated by diplomat-tool import type { BlockPos } from "./BlockPos.mjs" import type { Dimensions } from "./Dimensions.mjs" import type { NucleationError } from "./NucleationError.mjs" import type { RegionBounds } from "./RegionBounds.mjs" import type { Schematic } from "./Schematic.mjs" import type { pointer, codepoint } from "./diplomat-runtime.d.ts"; /** * A named sub-volume of a schematic: a union of boxes plus a metadata map. */ export class DefinitionRegion { /** @internal */ get ffiValue(): pointer; /** @internal */ constructor(); /** * Create a new empty region (no boxes, no metadata). */ static create(): DefinitionRegion; /** * A region consisting of a single inclusive box. Min/max are swapped * per axis if given out of order. */ static fromBounds(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): DefinitionRegion; /** * Build a region from single-block positions crossing as flat `[i32]` * chunked in threes (PORTING rule 7). Errors with `InvalidArgument` if * the length is not a multiple of 3. */ static fromPositions(positions: Array): DefinitionRegion; /** * Build a region from bounding boxes crossing as flat `[i32]` chunked in * sixes (`min_x, min_y, min_z, max_x, max_y, max_z` per box). Errors * with `InvalidArgument` if the length is not a multiple of 6. */ static fromBoundingBoxes(boxes: Array): DefinitionRegion; /** * Add an inclusive box to the region. Min/max are swapped per axis if * given out of order. */ addBounds(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): void; /** * Add a single block position (a 1x1x1 box) to the region. */ addPoint(x: number, y: number, z: number): void; /** * Set a metadata entry (insert or overwrite the key). */ setMetadata(key: string, value: string): void; /** * Errors with `NotFound` when the key is absent. */ getMetadata(key: string): string; /** * The full metadata map, written as a JSON object string (the old ABI * returned an array of `"key=value"` strings). */ allMetadataJson(): string; /** * The metadata keys, written as a JSON array string. */ metadataKeysJson(): string; /** * Store a filter expression in the region's metadata under the `filter` * key. */ addFilter(filter: string): void; /** * `true` if the region contains no boxes. */ isEmpty(): boolean; /** * The total volume in blocks, summed box by box: positions covered by * several overlapping boxes are counted once per box. */ volume(): bigint; /** * Whether the position lies inside any of the region's boxes. */ contains(x: number, y: number, z: number): boolean; /** * Translate every box by (`dx`, `dy`, `dz`) in place. */ shift(dx: number, dy: number, dz: number): void; /** * Grow every box in place by (`x`, `y`, `z`) outward on both sides of * each axis. Negative values contract; boxes that shrink away are * removed. */ expand(x: number, y: number, z: number): void; /** * Shrink every box in place by `amount` on all sides (the inverse of * a uniform `expand`); boxes that shrink away are removed. */ contract(amount: number): void; /** * A new region: the intersection of `self` and `other`. */ intersected(other: DefinitionRegion): DefinitionRegion; /** * A new region: the union of `self` and `other`. */ unionWith(other: DefinitionRegion): DefinitionRegion; /** * A new region: `self` minus `other`. */ subtracted(other: DefinitionRegion): DefinitionRegion; /** * Merge `other`'s boxes and metadata into `self`. */ merge(other: DefinitionRegion): void; /** * Union `other`'s boxes into `self` in place. */ unionInto(other: DefinitionRegion): void; /** * The overall bounding box. Errors with `NotFound` when the region is * empty. */ bounds(): RegionBounds; /** * The (width, height, length) of the overall bounding box; all zeros * when the region is empty. */ dimensions(): Dimensions; /** * The center block position. Errors with `NotFound` when the region is * empty. */ center(): BlockPos; /** * The exact (fractional) center, written as a JSON `[x, y, z]` array of * floats. Errors with `NotFound` when the region is empty. */ centerF32Json(): string; /** * Every contained position, written as a flat JSON array of ints * (`[x0, y0, z0, x1, y1, z1, …]`), deduplicated, in box order. */ positionsJson(): string; /** * Every contained position in sorted (y, z, x) order, written as a flat * JSON array of ints. */ positionsSortedJson(): string; /** * The number of boxes making up this region. */ boxCount(): number; /** * The box at `index`. Errors with `NotFound` when out of range. */ getBox(index: number): RegionBounds; /** * Every box, written as a flat JSON array of ints (six ints per box: * `min_x, min_y, min_z, max_x, max_y, max_z`). */ boxesJson(): string; /** * Whether all positions form a single face-connected (6-connectivity) * component. `true` for empty and single-block regions. */ isContiguous(): boolean; /** * The number of face-connected (6-connectivity) components; 0 when * the region is empty. */ connectedComponents(): number; /** * Merge overlapping/adjacent boxes into a minimal representation. */ simplify(): void; /** * A new region containing only the positions where `schematic` has a * block named `block_name`. */ filterByBlock(schematic: Schematic, blockName: string): DefinitionRegion; /** * A new region containing only the positions where the block in * `schematic` matches every property in `properties_json` (a JSON * object of property name → value strings). */ filterByProperties(schematic: Schematic, propertiesJson: string): DefinitionRegion; /** * Remove every position where `schematic` has a block named * `block_name` (in place). */ excludeBlock(schematic: Schematic, blockName: string): void; /** * Whether any of the region's boxes intersects the given inclusive * box (useful for frustum culling). */ intersectsBounds(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): boolean; /** * A new region shifted by (`dx`, `dy`, `dz`). */ shifted(dx: number, dy: number, dz: number): DefinitionRegion; /** * A new region expanded by (`x`, `y`, `z`) on each axis. */ expanded(x: number, y: number, z: number): DefinitionRegion; /** * A new region contracted by `amount` on every axis. */ contracted(amount: number): DefinitionRegion; /** * A deep copy of this region. */ copy(): DefinitionRegion; /** * Store a display color (`0xRRGGBB`) in the region's metadata. */ setColor(color: number): void; /** * The blocks of `schematic` inside this region, written as a JSON array * of `{"x", "y", "z", "name", "properties"}` objects (the old ABI * returned a `CBlockArray`). */ blocksJson(schematic: Schematic): string; /** * Write this region into `schematic`'s definition-region map under * `name` (insert or overwrite). */ sync(schematic: Schematic, name: string): void; }