Documentation

Chunk
in package

Table of Contents

COORD_BIT_SIZE  = \pocketmine\world\format\SubChunk::COORD_BIT_SIZE
COORD_MASK  = \pocketmine\world\format\SubChunk::COORD_MASK
DIRTY_FLAG_BIOMES  = 1 << 3
DIRTY_FLAG_BLOCKS  = 1 << 0
EDGE_LENGTH  = \pocketmine\world\format\SubChunk::EDGE_LENGTH
MAX_SUBCHUNK_INDEX  = 15
MAX_SUBCHUNKS  = self::MAX_SUBCHUNK_INDEX - self::MIN_SUBCHUNK_INDEX + 1
MIN_SUBCHUNK_INDEX  = 0
$biomeIds  : BiomeArray
$heightMap  : HeightArray
$lightPopulated  : bool|null
$subChunks  : SplFixedArray|array<string|int, SubChunk>
$terrainPopulated  : bool
$tiles  : array<string|int, Tile>
$terrainDirtyFlags  : int
__clone()  : mixed
__construct()  : mixed
addTile()  : void
blockHash()  : int
Hashes the given chunk block coordinates into a single integer.
clearTerrainDirtyFlags()  : void
collectGarbage()  : void
Disposes of empty subchunks and frees data where possible
getBiomeId()  : int
Returns the biome ID at the specified X/Z chunk block coordinates
getBiomeIdArray()  : string
getFullBlock()  : int
Returns the internal ID of the blockstate at the given coordinates.
getHeight()  : int
Returns the chunk height in count of subchunks.
getHeightMap()  : int
Returns the heightmap value at the specified X/Z chunk block coordinates
getHeightMapArray()  : array<string|int, int>
getHighestBlockAt()  : int|null
Returns the Y coordinate of the highest non-air block at the specified X/Z chunk block coordinates
getSubChunk()  : SubChunk
getSubChunks()  : array<string|int, SubChunk>
getTerrainDirtyFlag()  : bool
getTerrainDirtyFlags()  : int
getTile()  : Tile|null
Returns the tile at the specified chunk block coordinates, or null if no tile exists.
getTiles()  : array<string|int, Tile>
isLightPopulated()  : bool|null
isPopulated()  : bool
isTerrainDirty()  : bool
onUnload()  : void
Called when the chunk is unloaded, closing entities and tiles.
removeTile()  : void
setBiomeId()  : void
Sets the biome ID at the specified X/Z chunk block coordinates
setFullBlock()  : void
Sets the blockstate at the given coordinate by internal ID.
setHeightMap()  : void
Returns the heightmap value at the specified X/Z chunk block coordinates
setHeightMapArray()  : void
setLightPopulated()  : void
setPopulated()  : void
setSubChunk()  : void
Sets a subchunk in the chunk index
setTerrainDirty()  : void
setTerrainDirtyFlag()  : void

Constants

COORD_BIT_SIZE

public mixed COORD_BIT_SIZE = \pocketmine\world\format\SubChunk::COORD_BIT_SIZE

COORD_MASK

public mixed COORD_MASK = \pocketmine\world\format\SubChunk::COORD_MASK

DIRTY_FLAG_BIOMES

public mixed DIRTY_FLAG_BIOMES = 1 << 3

DIRTY_FLAG_BLOCKS

public mixed DIRTY_FLAG_BLOCKS = 1 << 0

EDGE_LENGTH

public mixed EDGE_LENGTH = \pocketmine\world\format\SubChunk::EDGE_LENGTH

MAX_SUBCHUNK_INDEX

public mixed MAX_SUBCHUNK_INDEX = 15

MAX_SUBCHUNKS

public mixed MAX_SUBCHUNKS = self::MAX_SUBCHUNK_INDEX - self::MIN_SUBCHUNK_INDEX + 1

MIN_SUBCHUNK_INDEX

public mixed MIN_SUBCHUNK_INDEX = 0

Properties

$lightPopulated

protected bool|null $lightPopulated = false

$subChunks

protected SplFixedArray|array<string|int, SubChunk> $subChunks
Tags
phpstan-var

\SplFixedArray<SubChunk>

$terrainPopulated

protected bool $terrainPopulated = false

$tiles

protected array<string|int, Tile> $tiles = []

$terrainDirtyFlags

private int $terrainDirtyFlags = 0

Methods

__clone()

public __clone() : mixed
Return values
mixed

__construct()

public __construct(array<string|int, SubChunk$subChunks, BiomeArray $biomeIds, bool $terrainPopulated) : mixed
Parameters
$subChunks : array<string|int, SubChunk>
$biomeIds : BiomeArray
$terrainPopulated : bool
Return values
mixed

addTile()

public addTile(Tile $tile) : void
Parameters
$tile : Tile
Return values
void

blockHash()

Hashes the given chunk block coordinates into a single integer.

public static blockHash(int $x, int $y, int $z) : int
Parameters
$x : int

0-15

$y : int

0-255

$z : int

0-15

Return values
int

clearTerrainDirtyFlags()

public clearTerrainDirtyFlags() : void
Return values
void

collectGarbage()

Disposes of empty subchunks and frees data where possible

public collectGarbage() : void
Return values
void

getBiomeId()

Returns the biome ID at the specified X/Z chunk block coordinates

public getBiomeId(int $x, int $z) : int
Parameters
$x : int

0-15

$z : int

0-15

Return values
int

0-255

getBiomeIdArray()

public getBiomeIdArray() : string
Return values
string

getFullBlock()

Returns the internal ID of the blockstate at the given coordinates.

public getFullBlock(int $x, int $y, int $z) : int
Parameters
$x : int

0-15

$y : int

0-255

$z : int

0-15

Return values
int

bitmap, (id << 4) | meta

getHeight()

Returns the chunk height in count of subchunks.

public getHeight() : int
Return values
int

getHeightMap()

Returns the heightmap value at the specified X/Z chunk block coordinates

public getHeightMap(int $x, int $z) : int
Parameters
$x : int

0-15

$z : int

0-15

Return values
int

getHeightMapArray()

public getHeightMapArray() : array<string|int, int>
Return values
array<string|int, int>

getHighestBlockAt()

Returns the Y coordinate of the highest non-air block at the specified X/Z chunk block coordinates

public getHighestBlockAt(int $x, int $z) : int|null
Parameters
$x : int

0-15

$z : int

0-15

Return values
int|null

0-255, or null if there are no blocks in the column

getSubChunks()

public getSubChunks() : array<string|int, SubChunk>
Tags
phpstan-return

array<int, SubChunk>

Return values
array<string|int, SubChunk>

getTerrainDirtyFlag()

public getTerrainDirtyFlag(int $flag) : bool
Parameters
$flag : int
Return values
bool

getTerrainDirtyFlags()

public getTerrainDirtyFlags() : int
Return values
int

getTile()

Returns the tile at the specified chunk block coordinates, or null if no tile exists.

public getTile(int $x, int $y, int $z) : Tile|null
Parameters
$x : int

0-15

$y : int

0-255

$z : int

0-15

Return values
Tile|null

getTiles()

public getTiles() : array<string|int, Tile>
Return values
array<string|int, Tile>

isLightPopulated()

public isLightPopulated() : bool|null
Return values
bool|null

isPopulated()

public isPopulated() : bool
Return values
bool

isTerrainDirty()

public isTerrainDirty() : bool
Return values
bool

onUnload()

Called when the chunk is unloaded, closing entities and tiles.

public onUnload() : void
Return values
void

removeTile()

public removeTile(Tile $tile) : void
Parameters
$tile : Tile
Return values
void

setBiomeId()

Sets the biome ID at the specified X/Z chunk block coordinates

public setBiomeId(int $x, int $z, int $biomeId) : void
Parameters
$x : int

0-15

$z : int

0-15

$biomeId : int

0-255

Return values
void

setFullBlock()

Sets the blockstate at the given coordinate by internal ID.

public setFullBlock(int $x, int $y, int $z, int $block) : void
Parameters
$x : int
$y : int
$z : int
$block : int
Return values
void

setHeightMap()

Returns the heightmap value at the specified X/Z chunk block coordinates

public setHeightMap(int $x, int $z, int $value) : void
Parameters
$x : int

0-15

$z : int

0-15

$value : int
Return values
void

setHeightMapArray()

public setHeightMapArray(array<string|int, int> $values) : void
Parameters
$values : array<string|int, int>
Return values
void

setLightPopulated()

public setLightPopulated([bool|null $value = true ]) : void
Parameters
$value : bool|null = true
Return values
void

setPopulated()

public setPopulated([bool $value = true ]) : void
Parameters
$value : bool = true
Return values
void

setSubChunk()

Sets a subchunk in the chunk index

public setSubChunk(int $y, SubChunk|null $subChunk) : void
Parameters
$y : int
$subChunk : SubChunk|null
Return values
void

setTerrainDirty()

public setTerrainDirty() : void
Return values
void

setTerrainDirtyFlag()

public setTerrainDirtyFlag(int $flag, bool $value) : void
Parameters
$flag : int
$value : bool
Return values
void

Search results