[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/native-worldgen](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/index.md) / [NativeWorldgen](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md) / NativeWorldgen

# Class: NativeWorldgen

Defined in: [NativeWorldgen.ts:298](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L298)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L536)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L541)

Unloads the library. Destroy its stacks first.

#### Returns

`void`

***

### createAquifer()

> **createAquifer**(`source`): [`NativeAquifer`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeAquifer.md)

Defined in: [NativeWorldgen.ts:479](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L479)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md#nativeaquifersource)

Its programs, seed, extent and fluids.

#### Returns

[`NativeAquifer`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeAquifer.md)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeCellProgram.md)

Defined in: [NativeWorldgen.ts:451](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L451)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md#nativecellsource)

The program's records.

#### Returns

[`NativeCellProgram`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeCellProgram.md)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeClimateSearch.md)

Defined in: [NativeWorldgen.ts:422](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L422)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md#nativeclimatesource)

The flattened tree.

#### Returns

[`NativeClimateSearch`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeClimateSearch.md)

The tree.

#### Throws

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

***

### createProgram()

> **createProgram**(`source`): [`NativeDensityProgram`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeDensityProgram.md)

Defined in: [NativeWorldgen.ts:391](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L391)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md#nativeprogramsource)

The encoded program.

#### Returns

[`NativeDensityProgram`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeDensityProgram.md)

The program.

#### Throws

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

***

### createStack()

> **createStack**(`layers`): [`NativeNoiseStack`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeNoiseStack.md)

Defined in: [NativeWorldgen.ts:359](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L359)

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

#### Parameters

##### layers

readonly [`NativeNoiseLayer`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md#nativenoiselayer)[]

The octaves, summed in this order.

#### Returns

[`NativeNoiseStack`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeNoiseStack.md)

The stack.

#### Throws

When a table has other than 256 entries.

#### Throws

When the library cannot allocate it.

***

### createSurface()

> **createSurface**(`source`): [`NativeSurface`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeSurface.md)

Defined in: [NativeWorldgen.ts:507](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L507)

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`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/index.md#nativesurfacesource)

The program laid out for the C.

#### Returns

[`NativeSurface`](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/NativeWorldgen/classes/NativeSurface.md)

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](https://github.com/JSPrismarine/JSPrismarine/blob/9db8dc5e83d04708d63ff9d73cae14f6c6b880f6/packages/native-worldgen/src/NativeWorldgen.ts#L327)

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

#### Parameters

##### path?

`string` = `...`

The library's file; [locateLibrary](https://jsprismarine.dev/api/@jsprismarine/native-worldgen/library/index.md#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`.
