Skip to content

API reference / @jsprismarine/native-worldgen / NativeWorldgen / NativeWorldgen

Class: NativeWorldgen ​

Defined in: NativeWorldgen.ts:298

The library, loaded once for this thread. Every call is synchronous, and each thread that loads it gets its own binding; stacks belong to the thread that made them.

Methods ​

biomeJitter() ​

biomeJitter(seedHi, seedLo, x, y, z): number

Defined in: NativeWorldgen.ts:536

The jitter bits of one biome lattice point, as Java's BiomeManager derives them.

Parameters ​

seedHi ​

number

The zoom seed's high 32 bits, unsigned.

seedLo ​

number

The zoom seed's low 32 bits, unsigned.

x ​

number

y ​

number

z ​

number

Returns ​

number

Bits 24 to 33 of the x, y and z offsets' generator steps, packed as x | y << 10 | z << 20.


close() ​

close(): void

Defined in: NativeWorldgen.ts:541

Unloads the library. Destroy its stacks first.

Returns ​

void


createAquifer() ​

createAquifer(source): NativeAquifer

Defined in: NativeWorldgen.ts:479

Registers the noise aquifer of one chunk extent, which decides each position's fluid in C with the same answers as @jsprismarine/worldgen's NoiseBasedAquifer.

Parameters ​

source ​

NativeAquiferSource

Its programs, seed, extent and fluids.

Returns ​

NativeAquifer

The aquifer, which keeps its programs alive.

Throws ​

When a program is destroyed, the extent is empty, the default fluid is not a fluid code, or memory runs out.


createCellProgram() ​

createCellProgram(source): NativeCellProgram

Defined in: NativeWorldgen.ts:451

Registers a cell program, which fills a whole interpolation cell in C with the same bits as the TypeScript CellProgram it was laid out by.

Parameters ​

source ​

NativeCellSource

The program's records.

Returns ​

NativeCellProgram

The program.

Throws ​

When a record names something out of range or runs a TypeScript fallback, the cell holds more than 4096 values, or memory runs out.


createClimate() ​

createClimate(source): NativeClimateSearch

Defined in: NativeWorldgen.ts:422

Registers a climate search tree, which finds the nearest box in C with the same answer as the TypeScript search, ties included.

Parameters ​

source ​

NativeClimateSource

The flattened tree.

Returns ​

NativeClimateSearch

The tree.

Throws ​

When a node names a child that does not exist, or memory runs out.


createProgram() ​

createProgram(source): NativeDensityProgram

Defined in: NativeWorldgen.ts:391

Registers a density program, which evaluates its tree in C one position at a time with the same bits as the closures it was encoded from.

Parameters ​

source ​

NativeProgramSource

The encoded program.

Returns ​

NativeDensityProgram

The program.

Throws ​

When a record names something out of range, or memory runs out.


createStack() ​

createStack(layers): NativeNoiseStack

Defined in: NativeWorldgen.ts:359

Registers an octave stack in native memory. Its values are NoiseStack.get3's, bit for bit.

Parameters ​

layers ​

readonly NativeNoiseLayer[]

The octaves, summed in this order.

Returns ​

NativeNoiseStack

The stack.

Throws ​

When a table has other than 256 entries.

Throws ​

When the library cannot allocate it.


createSurface() ​

createSurface(source): NativeSurface

Defined in: NativeWorldgen.ts:507

Registers a material rule program for the surface pass, which runs a chunk's columns in C with the same blocks as @jsprismarine/worldgen's MaterialRuleInterpreter.

Parameters ​

source ​

NativeSurfaceSource

The program laid out for the C.

Returns ​

NativeSurface

The program, which keeps its density programs alive.

Throws ​

When an op or record names something that does not exist, a vein's program is destroyed, or memory runs out.


load() ​

static load(path?): NativeWorldgen

Defined in: NativeWorldgen.ts:327

Loads the library and checks that it speaks this binding's interface.

Parameters ​

path? ​

string = ...

The library's file; locateLibrary finds it when absent.

Returns ​

NativeWorldgen

The bound library.

Throws ​

When there is no library, it does not load, or it speaks another interface. Every failure to load is one, so a caller can fall back on one instanceof.