PocketMine
Level Class Reference
Inheritance diagram for Level:
ChunkManager Metadatable

Public Member Functions

 getTickRate ()
 
 getTickRateTime ()
 
 setTickRate ($tickRate)
 
 initLevel ()
 
 registerGenerator ()
 
 unregisterGenerator ()
 
 getBlockMetadata ()
 
 getServer ()
 
 getProvider ()
 
 getId ()
 
 close ()
 
 addSound (Sound $sound, array $players=null)
 
 addParticle (Particle $particle, array $players=null)
 
 getAutoSave ()
 
 setAutoSave ($value)
 
 unload ($force=false)
 
 getUsingChunk ($chunkX, $chunkZ)
 
 getChunkPlayers ($chunkX, $chunkZ)
 
 getChunkLoaders ($chunkX, $chunkZ)
 
 addChunkPacket ($chunkX, $chunkZ, DataPacket $packet)
 
 registerChunkLoader (ChunkLoader $loader, $chunkX, $chunkZ, $autoLoad=true)
 
 unregisterChunkLoader (ChunkLoader $loader, $chunkX, $chunkZ)
 
 checkTime ()
 
 sendTime ()
 
 doTick ($currentTick)
 
 checkSleep ()
 
 sendBlockExtraData ($x, $y, $z, $id, $data, array $targets=null)
 
 sendBlocks (array $target, array $blocks, $flags=UpdateBlockPacket::FLAG_NONE, $optimizeRebuilds=false)
 
 clearCache ($full=false)
 
 clearChunkCache ($chunkX, $chunkZ)
 
 __debugInfo ()
 
 save ($force=false)
 
 saveChunks ()
 
 updateAround (Vector3 $pos)
 
 scheduleUpdate (Vector3 $pos, $delay)
 
 getCollisionBlocks (AxisAlignedBB $bb, $targetFirst=false)
 
 isFullBlock (Vector3 $pos)
 
 getCollisionCubes (Entity $entity, AxisAlignedBB $bb, $entities=true)
 
 getFullLight (Vector3 $pos)
 
 getFullBlock ($x, $y, $z)
 
 getBlock (Vector3 $pos, $cached=true)
 
 updateAllLight (Vector3 $pos)
 
 updateBlockSkyLight ($x, $y, $z)
 
 setBlock (Vector3 $pos, Block $block, $direct=false, $update=true)
 
 dropItem (Vector3 $source, Item $item, Vector3 $motion=null, $delay=10)
 
 useBreakOn (Vector3 $vector, Item &$item=null, Player $player=null, $createParticles=false)
 
 useItemOn (Vector3 $vector, Item &$item, $face, $fx=0.0, $fy=0.0, $fz=0.0, Player $player=null)
 
 getEntity ($entityId)
 
 getEntities ()
 
 getCollidingEntities (AxisAlignedBB $bb, Entity $entity=null)
 
 getNearbyEntities (AxisAlignedBB $bb, Entity $entity=null)
 
 getTiles ()
 
 getTileById ($tileId)
 
 getPlayers ()
 
 getLoaders ()
 
 getTile (Vector3 $pos)
 
 getChunkEntities ($X, $Z)
 
 getChunkTiles ($X, $Z)
 
 getBlockIdAt ($x, $y, $z)
 
 setBlockIdAt ($x, $y, $z, $id)
 
 getBlockExtraDataAt ($x, $y, $z)
 
 setBlockExtraDataAt ($x, $y, $z, $id, $data)
 
 getBlockDataAt ($x, $y, $z)
 
 setBlockDataAt ($x, $y, $z, $data)
 
 getBlockSkyLightAt ($x, $y, $z)
 
 setBlockSkyLightAt ($x, $y, $z, $level)
 
 getBlockLightAt ($x, $y, $z)
 
 setBlockLightAt ($x, $y, $z, $level)
 
 getBiomeId ($x, $z)
 
 getBiomeColor ($x, $z)
 
 getHeightMap ($x, $z)
 
 setBiomeId ($x, $z, $biomeId)
 
 setBiomeColor ($x, $z, $R, $G, $B)
 
 setHeightMap ($x, $z, $value)
 
 getChunks ()
 
 getChunk ($x, $z, $create=false)
 
 getChunkAt ($x, $z, $create=false)
 
 generateChunkCallback ($x, $z, FullChunk $chunk)
 
 setChunk ($chunkX, $chunkZ, FullChunk $chunk=null, $unload=true)
 
 getHighestBlockAt ($x, $z)
 
 isChunkLoaded ($x, $z)
 
 isChunkGenerated ($x, $z)
 
 isChunkPopulated ($x, $z)
 
 getSpawnLocation ()
 
 setSpawnLocation (Vector3 $pos)
 
 requestChunk ($x, $z, Player $player)
 
 removeEntity (Entity $entity)
 
 addEntity (Entity $entity)
 
 addTile (Tile $tile)
 
 removeTile (Tile $tile)
 
 isChunkInUse ($x, $z)
 
 loadChunk ($x, $z, $generate=true)
 
 unloadChunkRequest ($x, $z, $safe=true)
 
 cancelUnloadChunkRequest ($x, $z)
 
 unloadChunk ($x, $z, $safe=true, $trySave=true)
 
 isSpawnChunk ($X, $Z)
 
 getSpawn ()
 
 getSafeSpawn ($spawn=null)
 
 setSpawn (Vector3 $pos)
 
 getTime ()
 
 getName ()
 
 getFolderName ()
 
 setTime ($time)
 
 stopTime ()
 
 startTime ()
 
 getSeed ()
 
 setSeed ($seed)
 
 populateChunk ($x, $z, $force=false)
 
 generateChunk ($x, $z, $force=false)
 
 regenerateChunk ($x, $z)
 
 doChunkGarbageCollection ()
 
 unloadChunks ($force=false)
 
 setMetadata ($metadataKey, MetadataValue $metadataValue)
 
 getMetadata ($metadataKey)
 
 hasMetadata ($metadataKey)
 
 removeMetadata ($metadataKey, Plugin $plugin)
 
 addEntityMotion ($chunkX, $chunkZ, $entityId, $x, $y, $z)
 
 addEntityMovement ($chunkX, $chunkZ, $entityId, $x, $y, $z, $yaw, $pitch, $headYaw=null)
 
- Public Member Functions inherited from ChunkManager
 getChunk ($chunkX, $chunkZ)
 
 setChunk ($chunkX, $chunkZ, FullChunk $chunk=null)
 

Static Public Member Functions

static chunkHash ($x, $z)
 
static blockHash ($x, $y, $z)
 
static chunkBlockHash ($x, $y, $z)
 
static getBlockXYZ ($hash, &$x, &$y, &$z)
 
static getXZ ($hash, &$x, &$z)
 
static generateChunkLoaderId (ChunkLoader $loader)
 

Data Fields

const BLOCK_UPDATE_NORMAL = 1
 
const BLOCK_UPDATE_RANDOM = 2
 
const BLOCK_UPDATE_SCHEDULED = 3
 
const BLOCK_UPDATE_WEAK = 4
 
const BLOCK_UPDATE_TOUCH = 5
 
const TIME_DAY = 0
 
const TIME_SUNSET = 12000
 
const TIME_NIGHT = 14000
 
const TIME_SUNRISE = 23000
 
const TIME_FULL = 24000
 
 $updateEntities = []
 
 $updateTiles = []
 
 $stopTime
 
 $sleepTicks = 0
 
 $timings
 
 $tickRateTime = 0
 
 $tickRateCounter = 0
 

Static Public Attributes

static $COMPRESSION_LEVEL = 8
 

Member Function Documentation

addEntity ( Entity  $entity)
Parameters
Entity$entity
Exceptions
LevelException
addTile ( Tile  $tile)
Parameters
Tile$tile
Exceptions
LevelException
checkTime ( )

WARNING: Do not use this, it's only for internal use. Changes to this function won't be recorded on the version.

static chunkHash (   $x,
  $z 
)
static

Returns the chunk unique hash/key

Parameters
int$x
int$z
Returns
string
doTick (   $currentTick)

WARNING: Do not use this, it's only for internal use. Changes to this function won't be recorded on the version.

Parameters
int$currentTick
Returns
bool
dropItem ( Vector3  $source,
Item  $item,
Vector3  $motion = null,
  $delay = 10 
)
Parameters
Vector3$source
Item$item
Vector3$motion
int$delay
getAutoSave ( )
Returns
bool
getBiomeColor (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
int[]
getBiomeId (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
int
getBlock ( Vector3  $pos,
  $cached = true 
)

Gets the Block object on the Vector3 location

Parameters
Vector3$pos
boolean$cached
Returns
Block
getBlockDataAt (   $x,
  $y,
  $z 
)

Gets the raw block metadata

Parameters
int$x
int$y
int$z
Returns
int 0-15

Implements ChunkManager.

getBlockExtraDataAt (   $x,
  $y,
  $z 
)

Gets the raw block extra data

Parameters
int$x
int$y
int$z
Returns
int 16-bit
getBlockIdAt (   $x,
  $y,
  $z 
)

Gets the raw block id.

Parameters
int$x
int$y
int$z
Returns
int 0-255

Implements ChunkManager.

getBlockLightAt (   $x,
  $y,
  $z 
)

Gets the raw block light level

Parameters
int$x
int$y
int$z
Returns
int 0-15
getBlockMetadata ( )
Returns
BlockMetadataStore
getBlockSkyLightAt (   $x,
  $y,
  $z 
)

Gets the raw block skylight level

Parameters
int$x
int$y
int$z
Returns
int 0-15
getChunk (   $x,
  $z,
  $create = false 
)

Gets the Chunk object

Parameters
int$x
int$z
bool$createWhether to generate the chunk if it does not exist
Returns
FullChunk|Chunk
getChunkAt (   $x,
  $z,
  $create = false 
)
Parameters
int$x
int$z
bool$create
Returns
FullChunk|Chunk
Deprecated:
getChunkEntities (   $X,
  $Z 
)

Returns a list of the entities on a given chunk

Parameters
int$X
int$Z
Returns
Entity[]
getChunkLoaders (   $chunkX,
  $chunkZ 
)

Gets the chunk loaders being used in a specific chunk

Parameters
int$chunkX
int$chunkZ
Returns
ChunkLoader[]
getChunkPlayers (   $chunkX,
  $chunkZ 
)

Gets the players being used in a specific chunk

Parameters
int$chunkX
int$chunkZ
Returns
Player[]
getChunks ( )
Returns
FullChunk[]|Chunk[]
getChunkTiles (   $X,
  $Z 
)

Gives a list of the Tile entities on a given chunk

Parameters
int$X
int$Z
Returns
Tile[]
getCollidingEntities ( AxisAlignedBB  $bb,
Entity  $entity = null 
)

Returns the entities colliding the current one inside the AxisAlignedBB

Parameters
AxisAlignedBB$bb
Entity$entity
Returns
Entity[]
getCollisionBlocks ( AxisAlignedBB  $bb,
  $targetFirst = false 
)
Parameters
AxisAlignedBB$bb
bool$targetFirst
Returns
Block[]
getCollisionCubes ( Entity  $entity,
AxisAlignedBB  $bb,
  $entities = true 
)
Parameters
Entity$entity
AxisAlignedBB$bb
boolean$entities
Returns
AxisAlignedBB[]
getEntities ( )

Gets the list of all the entities in this level

Returns
Entity[]
getEntity (   $entityId)
Parameters
int$entityId
Returns
Entity
getFolderName ( )

Returns the Level folder name

Returns
string
getFullBlock (   $x,
  $y,
  $z 
)
Parameters
$x
$y
$z
Returns
int bitmap, (id << 4) | data
getHeightMap (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
int
getHighestBlockAt (   $x,
  $z 
)

Gets the highest block Y value at a specific $x and $z

Parameters
int$x
int$z
Returns
int 0-127
getId ( )
final

Returns the unique level identifier

Returns
int
getLoaders ( )
Returns
ChunkLoader[]
getMetadata (   $metadataKey)

Returns a list of previously set metadata values from the implementing object's metadata store.

Parameters
string$metadataKey
Returns
MetadataValue[]

Implements Metadatable.

getName ( )

Returns the Level name

Returns
string
getNearbyEntities ( AxisAlignedBB  $bb,
Entity  $entity = null 
)

Returns the entities near the current one inside the AxisAlignedBB

Parameters
AxisAlignedBB$bb
Entity$entity
Returns
Entity[]
getPlayers ( )

Returns a list of the players in this level

Returns
Player[]
getProvider ( )
final
Returns
LevelProvider
getSafeSpawn (   $spawn = null)
Parameters
Vector3$spawndefault null
Returns
bool|Position
getSeed ( )

Gets the level seed

Returns
int

Implements ChunkManager.

getServer ( )
Returns
Server
getSpawn ( )

Returns the raw spawnpoint

Deprecated:
Returns
Position
getSpawnLocation ( )

Returns a Position pointing to the spawn

Returns
Position
getTile ( Vector3  $pos)

Returns the Tile in a position, or null if not found

Parameters
Vector3$pos
Returns
Tile
getTileById (   $tileId)
Parameters
$tileId
Returns
Tile
getTiles ( )

Returns a list of the Tile entities in this level

Returns
Tile[]
getTime ( )

Gets the current time

Returns
int
getUsingChunk (   $chunkX,
  $chunkZ 
)
Deprecated:
Use Level->getChunkPlayers($chunkX, $chunkZ)
hasMetadata (   $metadataKey)

Tests to see whether the implementing object contains the given metadata value in its metadata store.

Parameters
string$metadataKey
Returns
boolean

Implements Metadatable.

isChunkGenerated (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
bool
isChunkInUse (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
bool
isChunkLoaded (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
bool
isChunkPopulated (   $x,
  $z 
)
Parameters
int$x
int$z
Returns
bool
isFullBlock ( Vector3  $pos)
Parameters
Vector3$pos
Returns
bool
isSpawnChunk (   $X,
  $Z 
)

Returns true if the spawn is part of the spawn

Parameters
int$X
int$Z
Returns
bool
loadChunk (   $x,
  $z,
  $generate = true 
)
Parameters
int$x
int$z
bool$generate
Returns
bool
removeEntity ( Entity  $entity)

Removes the entity from the level index

Parameters
Entity$entity
Exceptions
LevelException
removeMetadata (   $metadataKey,
Plugin  $owningPlugin 
)

Removes the given metadata value from the implementing object's metadata store.

Parameters
string$metadataKey
Plugin$owningPlugin
Returns
void

Implements Metadatable.

removeTile ( Tile  $tile)
Parameters
Tile$tile
Exceptions
LevelException
save (   $force = false)
Parameters
bool$force
Returns
bool
scheduleUpdate ( Vector3  $pos,
  $delay 
)
Parameters
Vector3$pos
int$delay
sendBlocks ( array  $target,
array  $blocks,
  $flags = UpdateBlockPacket::FLAG_NONE,
  $optimizeRebuilds = false 
)
Parameters
Player[]$target
Block[]$blocks
int$flags
bool$optimizeRebuilds
sendTime ( )

WARNING: Do not use this, it's only for internal use. Changes to this function won't be recorded on the version.

setAutoSave (   $value)
Parameters
bool$value
setBiomeColor (   $x,
  $z,
  $R,
  $G,
  $B 
)
Parameters
int$x
int$z
int$R
int$G
int$B
setBiomeId (   $x,
  $z,
  $biomeId 
)
Parameters
int$x
int$z
int$biomeId
setBlock ( Vector3  $pos,
Block  $block,
  $direct = false,
  $update = true 
)

Sets on Vector3 the data from a Block object, does block updates and puts the changes to the send queue.

If $direct is true, it'll send changes directly to players. if false, it'll be queued and the best way to send queued changes will be done in the next tick. This way big changes can be sent on a single chunk update packet instead of thousands of packets.

If $update is true, it'll get the neighbour blocks (6 sides) and update them. If you are doing big changes, you might want to set this to false, then update manually.

Parameters
Vector3$pos
Block$block
bool$direct
setBlockDataAt (   $x,
  $y,
  $z,
  $data 
)

Sets the raw block metadata.

Parameters
int$x
int$y
int$z
int$data0-15

Implements ChunkManager.

setBlockExtraDataAt (   $x,
  $y,
  $z,
  $id,
  $data 
)

Sets the raw block metadata.

Parameters
int$x
int$y
int$z
int$id
int$data
setBlockIdAt (   $x,
  $y,
  $z,
  $id 
)

Sets the raw block id.

Parameters
int$x
int$y
int$z
int$id0-255

Implements ChunkManager.

setBlockLightAt (   $x,
  $y,
  $z,
  $level 
)

Sets the raw block light level.

Parameters
int$x
int$y
int$z
int$level0-15
setBlockSkyLightAt (   $x,
  $y,
  $z,
  $level 
)

Sets the raw block skylight level.

Parameters
int$x
int$y
int$z
int$level0-15
setChunk (   $chunkX,
  $chunkZ,
FullChunk  $chunk = null,
  $unload = true 
)
Parameters
int$chunkX
int$chunkZ
FullChunk$chunk
bool$unload
setHeightMap (   $x,
  $z,
  $value 
)
Parameters
int$x
int$z
int$value
setMetadata (   $metadataKey,
MetadataValue  $newMetadataValue 
)

Sets a metadata value in the implementing object's metadata store.

Parameters
string$metadataKey
MetadataValue$newMetadataValue
Returns
void

Implements Metadatable.

setSeed (   $seed)

Sets the seed for the level

Parameters
int$seed
setSpawn ( Vector3  $pos)

Sets the spawnpoint

Parameters
Vector3$pos
Deprecated:
setSpawnLocation ( Vector3  $pos)

Sets the level spawn location

Parameters
Vector3$pos
setTime (   $time)

Sets the current time on the level

Parameters
int$time
startTime ( )

Start the time again, if it was stopped

stopTime ( )

Stops the time for the level, will not save the lock state to disk

unload (   $force = false)

Unloads the current level from memory safely

Parameters
bool$forcedefault false, force unload of default level
Returns
bool
updateAround ( Vector3  $pos)
Parameters
Vector3$pos
useBreakOn ( Vector3  $vector,
Item $item = null,
Player  $player = null,
  $createParticles = false 
)

Tries to break a block using a item, including Player time checks if available It'll try to lower the durability if Item is a tool, and set it to Air if broken.

Parameters
Vector3$vector
Item&$item(if null, can break anything)
Player$player
bool$createParticles
Returns
boolean
useItemOn ( Vector3  $vector,
Item $item,
  $face,
  $fx = 0.0,
  $fy = 0.0,
  $fz = 0.0,
Player  $player = null 
)

Uses a item on a position and face, placing it or activating the block

Parameters
Vector3$vector
Item$item
int$face
float$fxdefault 0.0
float$fydefault 0.0
float$fzdefault 0.0
Player$playerdefault null
Returns
boolean

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