Skip to content

API reference / @jsprismarine/prismarine / world/chunk/SubChunk

world/chunk/SubChunk ​

Classes ​

Interfaces ​

ReadonlySubChunk ​

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:28

A sub chunk that can be read and not written, which is what a chunk hands out.

A write goes through the chunk, which tells a save cut holding this sub chunk before the write lands (ADR 0018). Its storages are read-only too, since a write to one is a write to the sub chunk.

Extends ​

  • Pick<SubChunk, "getRevision" | "isEmpty" | "getBlock" | "getBlockRuntimeId" | "getBlockStorage" | "networkSerialize">

Properties ​

sourceVersion ​

readonly sourceVersion: SubChunkVersion

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:32

Methods ​

getBlock() ​

getBlock(bx, by?, bz?, layer?): BlockState

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:117

Returns the legacy block id in the given position.

Parameters ​
bx ​

number | Vector3

block x

by? ​

number = 0

block y

bz? ​

number = 0

block z

layer? ​

number = 0

block storage layer

Returns ​

BlockState

Inherited from ​

Pick.getBlock

getBlockRuntimeId() ​

getBlockRuntimeId(bx, by, bz, layer?): number

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:140

Gets the runtime Id of a block in the given storage layer.

Parameters ​
bx ​

number

block x

by ​

number

block y

bz ​

number

block z

layer? ​

number = 0

block storage layer

Returns ​

number

The block's runtime Id, or air's when the layer is empty.

Inherited from ​

Pick.getBlockRuntimeId

getBlockStorage() ​

getBlockStorage(layer?): ReadonlyBlockStorage | undefined

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:101

One layer's storage, without the array getStorages builds.

Parameters ​
layer? ​

number = 0

The block storage layer: 0 for blocks, 1 for what a waterlogged block holds.

Returns ​

ReadonlyBlockStorage | undefined

The storage, or undefined when the layer is empty.

Inherited from ​

Pick.getBlockStorage

getRevision() ​

getRevision(): number

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:52

Returns ​

number

Inherited from ​

SubChunk.getRevision

getStorages() ​

getStorages(): readonly ReadonlyBlockStorage[]

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:33

Returns ​

readonly ReadonlyBlockStorage[]

isEmpty() ​

isEmpty(): boolean

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:63

Returns if the SubChunk is all air (basically empty).

Returns ​

boolean

Inherited from ​

SubChunk.isEmpty

networkSerialize() ​

networkSerialize(stream): void

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:148

Parameters ​
stream ​

BinaryStream

Returns ​

void

Inherited from ​

SubChunk.networkSerialize

Type Aliases ​

SubChunkVersion ​

SubChunkVersion = 1 | 8 | 9

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:13

1 is the original single-layer form, 8 adds a layer count, 9 adds the sub chunk's own index. The server writes 8 on the wire and 9 on disk, and reads all three from either.

Functions ​

isSubChunkVersion() ​

isSubChunkVersion(version): version is SubChunkVersion

Defined in: packages/prismarine/src/world/chunk/SubChunk.ts:18

Narrows a version byte read from disk or the wire to the sub chunk formats this server reads.

Parameters ​

version ​

number

Returns ​

version is SubChunkVersion