API reference / @jsprismarine/lighting / LightSection
Class: LightSection
Defined in: LightSection.ts:31
One light layer of one chunk section, 16 by 16 by 16 levels of 0 to 15 packed two per byte.
The 4096 levels take 2048 bytes, so a world with both layers resident costs 4 KiB per section rather than the 8 KiB a plain Uint8Array pair would. Cells are addressed in the same order the server's block storage uses, x major then z then y, so a section walk touches both arrays in step.
Levels are server-internal. See the package README: the Bedrock client renders light it computes itself and the protocol carries none.
Constructors
Constructor
new LightSection():
LightSection
Returns
LightSection
Accessors
byteLength
Get Signature
get byteLength():
number
Defined in: LightSection.ts:36
The size of the packed backing store in bytes, 2048 for the 4096 cells.
Returns
number
Methods
get()
get(
x,y,z):number
Defined in: LightSection.ts:48
The light level at a position inside the section.
Parameters
x
number
Section-local x, 0 to 15.
y
number
Section-local y, 0 to 15.
z
number
Section-local z, 0 to 15.
Returns
number
The level, 0 to 15.
Throws
When a coordinate falls outside the section.
isEmpty()
isEmpty():
boolean
Defined in: LightSection.ts:56
Whether every cell is dark, for border passes that need only re-seed lit sections.
Returns
boolean
set()
set(
x,y,z,level):void
Defined in: LightSection.ts:68
Writes the light level at a position inside the section.
Parameters
x
number
Section-local x, 0 to 15.
y
number
Section-local y, 0 to 15.
z
number
Section-local z, 0 to 15.
level
number
The level to store, 0 to 15.
Returns
void
Throws
When a coordinate falls outside the section or the level is not 0 to 15.