Skip to main content

A utility class for extracting and inserting voxel data from and into numbers.

The voxel data is stored in the following format:

  • Voxel type: 0x0000ffff
  • Rotation: 0x000f0000
  • Y-rotation: 0x00f00000
  • Stage: 0xff000000

TODO-DOCS For more information about voxel data, see here

Example

// Insert a voxel type 13 into zero.
const number = VoxelUtils.insertID(0, 13);

Methods

evaluateBlockRule

evaluateBlockRule(rule, voxel, functions): boolean

Parameters

NameType
ruleBlockRule
voxelCoords3
functionsObject
functions.getVoxelAt(x: number, y: number, z: number) => number
functions.getVoxelRotationAt(x: number, y: number, z: number) => BlockRotation
functions.getVoxelStageAt(x: number, y: number, z: number) => number

Returns

boolean


extractID

extractID(voxel): number

Extract the voxel id from a number.

Parameters

NameTypeDescription
voxelnumberThe voxel value to extract from.

Returns

number

The extracted voxel id.


extractRotation

extractRotation(voxel): BlockRotation

Extract the voxel rotation from a number.

Parameters

NameTypeDescription
voxelnumberThe voxel value to extract from.

Returns

BlockRotation

The extracted voxel rotation.


extractStage

extractStage(voxel): number

Extract the voxel stage from a number.

Parameters

NameTypeDescription
voxelnumberThe voxel value to extract from.

Returns

number

The extracted voxel stage.


getBlockEntityId

getBlockEntityId(id, voxel): string

Parameters

NameType
idstring
voxelCoords3

Returns

string


getBlockRotatedTransparency

getBlockRotatedTransparency(block, rotation): boolean[]

Parameters

NameType
blockBlock
rotationBlockRotation

Returns

boolean[]


getBlockTorchLightLevel

getBlockTorchLightLevel(block, color): number

Parameters

NameType
blockBlock
colorLightColor

Returns

number


insertAll

insertAll(id, rotation?, stage?): number

Parameters

NameType
idnumber
rotation?BlockRotation
stage?number

Returns

number


insertID

insertID(voxel, id): number

Insert a voxel id into a number.

Parameters

NameTypeDescription
voxelnumberThe voxel value to insert the id into.
idnumberThe voxel id to insert.

Returns

number

The inserted voxel value.


insertRotation

insertRotation(voxel, rotation): number

Insert a voxel rotation into a number.

Parameters

NameTypeDescription
voxelnumberThe voxel value to insert the rotation into.
rotationBlockRotationThe voxel rotation to insert.

Returns

number

The inserted voxel value.


insertStage

insertStage(voxel, stage): number

Insert a voxel stage into a number.

Parameters

NameTypeDescription
voxelnumberThe voxel value to insert the stage into.
stagenumberThe voxel stage to insert.

Returns

number

The inserted voxel value.