Skip to content

API reference / @jsprismarine/prismarine / JavaStateTranslator

Class: JavaStateTranslator ​

Defined in: prismarine/src/world/generators/datadriven/javaTranslation.ts:37

Translates Java block states to the runtime ids a chunk stores.

One of these lives for as long as the generator does, so a world pays for each distinct state once rather than once per chunk.

Constructors ​

Constructor ​

new JavaStateTranslator(): JavaStateTranslator

Returns ​

JavaStateTranslator

Methods ​

bedrockRuntimeIdOf() ​

bedrockRuntimeIdOf(name, states): number

Defined in: prismarine/src/world/generators/datadriven/javaTranslation.ts:65

The runtime id for a Bedrock state that reached the generator already translated, which is what @jsprismarine/structures hands back for a block out of a structure template.

Parameters ​

name ​

string

states ​

Readonly<Record<string, string | number>>

Returns ​

number

The id, or UNKNOWN_RUNTIME_ID when this server's palette has no such state, which the caller treats the same way as an unmapped Java one.


runtimeIdOf() ​

runtimeIdOf(name, properties?): number

Defined in: prismarine/src/world/generators/datadriven/javaTranslation.ts:48

The runtime id for a Java state.

Parameters ​

name ​

string

properties? ​

Readonly<Record<string, string>>

Returns ​

number

The id, or UNKNOWN_RUNTIME_ID when the Java state has no Bedrock equivalent this server's palette knows. Callers place nothing for that rather than substituting a block, so a gap is visible as a hole and not as the wrong terrain.


unmappedStates() ​

unmappedStates(): readonly string[]

Defined in: prismarine/src/world/generators/datadriven/javaTranslation.ts:82

Every Java state the translator could not place, for a generator to report once.

Returns ​

readonly string[]