Genisys  Genisys API 1.9.3
A server software for Minecraft: Pocket Edition with many features
Chunk Class Reference

Public Member Functions

 __construct (int $chunkX, int $chunkZ, array $subChunks=[], array $entities=[], array $tiles=[], string $biomeIds="", array $heightMap=[])
 
 getX ()
 
 getZ ()
 
 setX (int $x)
 
 setZ (int $z)
 
 getHeight ()
 
 getFullBlock (int $x, int $y, int $z)
 
 setBlock (int $x, int $y, int $z, $blockId=null, $meta=null)
 
 getBlockId (int $x, int $y, int $z)
 
 setBlockId (int $x, int $y, int $z, int $id)
 
 getBlockData (int $x, int $y, int $z)
 
 setBlockData (int $x, int $y, int $z, int $data)
 
 getBlockExtraData (int $x, int $y, int $z)
 
 setBlockExtraData (int $x, int $y, int $z, int $data)
 
 getBlockSkyLight (int $x, int $y, int $z)
 
 setBlockSkyLight (int $x, int $y, int $z, int $level)
 
 getBlockLight (int $x, int $y, int $z)
 
 setBlockLight (int $x, int $y, int $z, int $level)
 
 getHighestBlockAt (int $x, int $z, bool $useHeightMap=true)
 
 getHeightMap (int $x, int $z)
 
 setHeightMap (int $x, int $z, int $value)
 
 recalculateHeightMap ()
 
 populateSkyLight ()
 
 getBiomeId (int $x, int $z)
 
 setBiomeId (int $x, int $z, int $biomeId)
 
 getBlockIdColumn (int $x, int $z)
 
 getBlockDataColumn (int $x, int $z)
 
 getBlockSkyLightColumn (int $x, int $z)
 
 getBlockLightColumn (int $x, int $z)
 
 isLightPopulated ()
 
 setLightPopulated (bool $value=true)
 
 isPopulated ()
 
 setPopulated (bool $value=true)
 
 isGenerated ()
 
 setGenerated (bool $value=true)
 
 addEntity (Entity $entity)
 
 removeEntity (Entity $entity)
 
 addTile (Tile $tile)
 
 removeTile (Tile $tile)
 
 getEntities ()
 
 getTiles ()
 
 getTile (int $x, int $y, int $z)
 
 unload (bool $safe=true)
 
 initChunk (Level $level)
 
 getBiomeIdArray ()
 
 getHeightMapArray ()
 
 getBlockExtraDataArray ()
 
 hasChanged ()
 
 setChanged (bool $value=true)
 
 getSubChunk (int $y, bool $generateNew=false)
 
 setSubChunk (int $y, SubChunk $subChunk=null, bool $allowEmpty=false)
 
 getSubChunks ()
 
 getHighestSubChunkIndex ()
 
 getSubChunkSendCount ()
 
 pruneEmptySubChunks ()
 
 networkSerialize ()
 
 fastSerialize ()
 

Static Public Member Functions

static fastDeserialize (string $data)
 
static getEmptyChunk (int $x, int $z)
 
static chunkBlockHash (int $x, int $y, int $z)
 

Data Fields

const MAX_SUBCHUNKS = 16
 

Protected Attributes

 $x
 
 $z
 
 $hasChanged = false
 
 $isInit = false
 
 $lightPopulated = false
 
 $terrainGenerated = false
 
 $terrainPopulated = false
 
 $height = Chunk::MAX_SUBCHUNKS
 
 $subChunks = []
 
 $emptySubChunk = null
 
 $tiles = []
 
 $tileList = []
 
 $entities = []
 
 $heightMap = []
 
 $biomeIds
 
 $extraData = []
 
 $NBTtiles = []
 
 $NBTentities = []
 

Constructor & Destructor Documentation

__construct ( int  $chunkX,
int  $chunkZ,
array  $subChunks = [],
array  $entities = [],
array  $tiles = [],
string  $biomeIds = "",
array  $heightMap = [] 
)
Parameters
int$chunkX
int$chunkZ
SubChunk[]$subChunks
CompoundTag[]$entities
CompoundTag[]$tiles
string$biomeIds
int[]$heightMap

Member Function Documentation

addEntity ( Entity  $entity)
Parameters
Entity$entity
addTile ( Tile  $tile)
Parameters
Tile$tile
static chunkBlockHash ( int  $x,
int  $y,
int  $z 
)
static

Creates a block hash from chunk block coordinates. Used for extra data keys in chunk packets.

static fastDeserialize ( string  $data)
static

Deserializes a fast-serialized chunk

Parameters
string$data
Returns
Chunk
fastSerialize ( )

Fast-serializes the chunk for passing between threads TODO: tiles and entities

Returns
string
getBiomeId ( int  $x,
int  $z 
)

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

Parameters
int$x0-15
int$z0-15
Returns
int 0-255
getBiomeIdArray ( )
Returns
string
getBlockData ( int  $x,
int  $y,
int  $z 
)

Returns the block meta value at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
Returns
int 0-15
getBlockDataColumn ( int  $x,
int  $z 
)

Returns a column of block meta values from bottom to top at the specified X/Z chunk block coordinates.

Parameters
int$x0-15
int$z0-15
Returns
string
getBlockExtraData ( int  $x,
int  $y,
int  $z 
)

Returns the raw block extra data value at the specified chunk block coordinates, or 0 if no data exists

Parameters
int$x0-15
int$y
int$z0-15
Returns
int bitmap, (meta << 8) | id
getBlockExtraDataArray ( )
Returns
int[]
getBlockId ( int  $x,
int  $y,
int  $z 
)

Returns the block ID at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
Returns
int 0-255
getBlockIdColumn ( int  $x,
int  $z 
)

Returns a column of block IDs from bottom to top at the specified X/Z chunk block coordinates.

Parameters
int$x0-15
int$z0-15
Returns
string
getBlockLight ( int  $x,
int  $y,
int  $z 
)

Returns the block light level at the specified chunk block coordinates

Parameters
int$x0-15
int$y0-15
int$z0-15
Returns
int 0-15
getBlockLightColumn ( int  $x,
int  $z 
)

Returns a column of block light values from bottom to top at the specified X/Z chunk block coordinates.

Parameters
int$x0-15
int$z0-15
Returns
string
getBlockSkyLight ( int  $x,
int  $y,
int  $z 
)

Returns the sky light level at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
Returns
int 0-15
getBlockSkyLightColumn ( int  $x,
int  $z 
)

Returns a column of sky light values from bottom to top at the specified X/Z chunk block coordinates.

Parameters
int$x0-15
int$z0-15
Returns
string
getEntities ( )

Returns an array of entities currently using this chunk.

Returns
Entity[]
getFullBlock ( int  $x,
int  $y,
int  $z 
)

Returns a bitmap of block ID and meta at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
Returns
int bitmap, (id << 4) | meta
getHeight ( )

Returns the chunk height in count of subchunks.

Returns
int
getHeightMap ( int  $x,
int  $z 
)

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

Parameters
int$x0-15
int$z0-15
Returns
int
getHeightMapArray ( )
Returns
int[]
getHighestBlockAt ( int  $x,
int  $z,
bool  $useHeightMap = true 
)

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

Parameters
int$x0-15
int$z0-15
bool$useHeightMapwhether to use pre-calculated heightmap values or not
Returns
int
getHighestSubChunkIndex ( )

Returns the Y coordinate of the highest non-empty subchunk in this chunk.

Returns
int
getSubChunk ( int  $y,
bool  $generateNew = false 
)

Returns the subchunk at the specified subchunk Y coordinate, or an empty, unmodifiable stub if it does not exist or the coordinate is out of range.

Parameters
int$y
bool$generateNewWhether to create a new, modifiable subchunk if there is not one in place
Returns
SubChunk|EmptySubChunk
getSubChunks ( )
Returns
SubChunk[]
getSubChunkSendCount ( )

Returns the count of subchunks that need sending to players

Returns
int
getTile ( int  $x,
int  $y,
int  $z 
)

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

Parameters
int$x0-15
int$y
int$z0-15
Returns
Tile|null
getTiles ( )
Returns
Tile[]
getX ( )
Returns
int
getZ ( )
Returns
int
hasChanged ( )
Returns
bool
initChunk ( Level  $level)

Deserializes tiles and entities from NBT

Parameters
Level$level
isGenerated ( )
Returns
bool
isLightPopulated ( )
Returns
bool
isPopulated ( )
Returns
bool
networkSerialize ( )

Serializes the chunk for sending to players

Returns
string
populateSkyLight ( )

Performs basic sky light population on the chunk.

TODO: rewrite this, use block light filters and diffusion, actual proper sky light population

pruneEmptySubChunks ( )

Disposes of empty subchunks

recalculateHeightMap ( )

Recalculates the heightmap for the whole chunk.

removeEntity ( Entity  $entity)
Parameters
Entity$entity
removeTile ( Tile  $tile)
Parameters
Tile$tile
setBiomeId ( int  $x,
int  $z,
int  $biomeId 
)

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

Parameters
int$x0-15
int$z0-15
int$biomeId0-255
setBlock ( int  $x,
int  $y,
int  $z,
  $blockId = null,
  $meta = null 
)

Sets block ID and meta in one call at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
int | null$blockId0-255 if null, does not change
int | null$meta0-15 if null, does not change
Returns
bool
setBlockData ( int  $x,
int  $y,
int  $z,
int  $data 
)

Sets the block meta value at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
int$data0-15
setBlockExtraData ( int  $x,
int  $y,
int  $z,
int  $data 
)

Sets the raw block extra data value at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
int$databitmap, (meta << 8) | id
setBlockId ( int  $x,
int  $y,
int  $z,
int  $id 
)

Sets the block ID at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
int$id0-255
setBlockLight ( int  $x,
int  $y,
int  $z,
int  $level 
)

Sets the block light level at the specified chunk block coordinates

Parameters
int$x0-15
int$y0-15
int$z0-15
int$level0-15
setBlockSkyLight ( int  $x,
int  $y,
int  $z,
int  $level 
)

Sets the sky light level at the specified chunk block coordinates

Parameters
int$x0-15
int$y
int$z0-15
int$level0-15
setChanged ( bool  $value = true)
Parameters
bool$value
setGenerated ( bool  $value = true)
Parameters
bool$value
setHeightMap ( int  $x,
int  $z,
int  $value 
)

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

Parameters
int$x0-15
int$z0-15
int$value
setLightPopulated ( bool  $value = true)
Parameters
bool$value
setPopulated ( bool  $value = true)
Parameters
bool$value
setSubChunk ( int  $y,
SubChunk  $subChunk = null,
bool  $allowEmpty = false 
)

Sets a subchunk in the chunk index

Parameters
int$y
SubChunk | null$subChunk
bool$allowEmptyWhether to check if the chunk is empty, and if so replace it with an empty stub
Returns
bool
setZ ( int  $z)
Parameters
int$z
unload ( bool  $safe = true)

Unloads the chunk, closing entities and tiles.

Parameters
bool$safeWhether to check if there are still players using this chunk
Returns
bool

The documentation for this class was generated from the following file: