Skip to main content

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

The light data is stored in the following format:

  • Sunlight: 0xff000000
  • Red light: 0x00ff0000
  • Green light: 0x0000ff00
  • Blue light: 0x000000ff

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

Example

// Insert a level 13 sunlight into zero.
const number = LightUtils.insertSunlight(0, 13);

Methods

canEnter

canEnter(source, target, dx, dy, dz): boolean

Check to see if light can enter from one block to another.

Parameters

NameTypeDescription
sourceboolean[]The source block's transparency.
targetboolean[]The target block's transparency.
dxnumberThe change in x direction.
dynumberThe change in y direction.
dznumberThe change in z direction.

Returns

boolean

Whether light can enter from the source block to the target block.


canEnterInto

canEnterInto(target, dx, dy, dz): boolean

Check to see if light can go "into" one block, disregarding the source.

Parameters

NameTypeDescription
targetboolean[]The target block's transparency.
dxnumberThe change in x direction.
dynumberThe change in y direction.
dznumberThe change in z direction.

Returns

boolean

Whether light can enter into the target block.


extractBlueLight

extractBlueLight(light): number

Extract the blue light level from a number.

Parameters

NameTypeDescription
lightnumberThe light value to extract from.

Returns

number

The extracted blue light value.


extractGreenLight

extractGreenLight(light): number

Extract the green light level from a number.

Parameters

NameTypeDescription
lightnumberThe light value to extract from.

Returns

number

The extracted green light value.


extractRedLight

extractRedLight(light): number

Extract the red light level from a number.

Parameters

NameTypeDescription
lightnumberThe light value to extract from.

Returns

number

The extracted red light value.


extractSunlight

extractSunlight(light): number

Extract the sunlight level from a number.

Parameters

NameTypeDescription
lightnumberThe light value to extract from.

Returns

number

The extracted sunlight value.


insertBlueLight

insertBlueLight(light, level): number

Insert a blue light level into a number.

Parameters

NameTypeDescription
lightnumberThe light value to insert the level into.
levelnumberThe blue light level to insert.

Returns

number

The inserted light value.


insertGreenLight

insertGreenLight(light, level): number

Insert a green light level into a number.

Parameters

NameTypeDescription
lightnumberThe light value to insert the level into.
levelnumberThe green light level to insert.

Returns

number

The inserted light value.


insertRedLight

insertRedLight(light, level): number

Insert a red light level into a number.

Parameters

NameTypeDescription
lightnumberThe light value to insert the level into.
levelnumberThe red light level to insert.

Returns

number

The inserted light value.


insertSunlight

insertSunlight(light, level): number

Insert a sunlight level into a number.

Parameters

NameTypeDescription
lightnumberThe light value to insert the level into.
levelnumberThe sunlight level to insert.

Returns

number

The inserted light value.