[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/generators/datadriven/javaStructureBeard

# world/generators/datadriven/javaStructureBeard

## Interfaces

### BeardPiece

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:22](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L22)

One structure piece the terrain is adapted around.

#### Properties

##### adaptation

> `readonly` **adaptation**: [`TerrainAdaptation`](#terrainadaptation)

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:26](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L26)

##### box

> `readonly` **box**: [`BoundingBox`](https://jsprismarine.dev/api/@jsprismarine/structures/index.md#boundingbox)

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:23](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L23)

##### groundLevelDelta

> `readonly` **groundLevelDelta**: `number`

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:25](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L25)

How far above the piece's floor its ground sits, Java's `getGroundLevelDelta`.

***

### Beardifier

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:266](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L266)

What [createBeardifier](#createbeardifier) builds for one chunk.

#### Properties

##### reaches

> `readonly` **reaches**: (`minX`, `maxX`, `minZ`, `maxZ`) => `boolean`

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:274](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L274)

Whether any piece or junction reaches a block in these columns. Where none does,
[Beardifier.sampler](#sampler) is exactly 0 at every height, so the terrain there is the
terrain of a chunk no structure reaches. Install as `SampleContext.beardifierReaches`.

###### Parameters

###### minX

`number`

###### maxX

`number`

###### minZ

`number`

###### maxZ

`number`

###### Returns

`boolean`

##### sampler

> `readonly` **sampler**: [`DensitySampler`](https://jsprismarine.dev/api/@jsprismarine/worldgen/index.md#densitysampler)

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:268](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L268)

The density contribution, to install as `SampleContext.beardifier`.

## Type Aliases

### BeardJunction

> **BeardJunction** = [`JigsawJunction`](https://jsprismarine.dev/api/@jsprismarine/structures/index.md#jigsawjunction)

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:30](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L30)

A jigsaw junction Java includes as a smaller beard contribution.

***

### TerrainAdaptation

> **TerrainAdaptation** = `"none"` \| `"bury"` \| `"beard_thin"` \| `"beard_box"` \| `"encapsulate"`

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:19](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L19)

The four `terrain_adaptation` values Java registers, plus the `none` every other structure has.

## Variables

### BEARD\_RADIUS

> `const` **BEARD\_RADIUS**: `12` = `12`

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:33](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L33)

How far from a piece the adaptation reaches.

## Functions

### createBeardifier()

> **createBeardifier**(`pieces`, `junctions?`): [`Beardifier`](#beardifier) \| `undefined`

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:202](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L202)

Builds the density contribution for the pieces near one chunk.

This sampler is the right operand of the top-level add in the overworld's `final_density`, so
it runs on all 98304 samples of a chunk and its per-sample cost is multiplied by that. The
pieces are therefore indexed by column: every adaptation's contribution is exactly zero once
the column is more than [BEARD\_RADIUS](#beard-radius) from the piece's box in x or in z, so a sample
only has to visit the pieces whose reach covers its own bucket. The index preserves the order
the pieces were given in, because the sum of several `float` contributions depends on it.

#### Parameters

##### pieces

readonly [`BeardPiece`](#beardpiece)[]

Every piece whose box comes within [BEARD\_RADIUS](#beard-radius) of the chunk. Pieces
  further away contribute nothing, so filtering before building this is what keeps the per
  block cost proportional to what is actually nearby.

##### junctions?

readonly [`JigsawJunction`](https://jsprismarine.dev/api/@jsprismarine/structures/index.md#jigsawjunction)[] = `[]`

Junction source positions in Java's structure-piece and connection order.

#### Returns

[`Beardifier`](#beardifier) \| `undefined`

The sampler and its reach, or undefined when no structure reaches the chunk, which is
  the common case and the one worth not paying for.

***

### fastInverseSqrt()

> **fastInverseSqrt**(`value`): `number`

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:53](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L53)

Java's `Mth.fastInvSqrt`: the Quake trick with one Newton step.

Reproduced rather than replaced by `1 / Math.sqrt(x)` because its answer is about four
decimal digits accurate, and the kernel it builds decides where the terrain under a village
ends up.

#### Parameters

##### value

`number`

#### Returns

`number`

#### Java Source

Mth.fastInvSqrt

***

### terrainAdaptationOf()

> **terrainAdaptationOf**(`value`): [`TerrainAdaptation`](#terrainadaptation)

Defined in: [packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts:385](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/generators/datadriven/javaStructureBeard.ts#L385)

The adaptation a `worldgen/structure` document asks for.

#### Parameters

##### value

`unknown`

#### Returns

[`TerrainAdaptation`](#terrainadaptation)
