PocketMine-MP 5.23.3 git-976fc63567edab7a6fb6aeae739f43cf9fe57de4
Loading...
Searching...
No Matches
pocketmine\world\World Class Reference
+ Inheritance diagram for pocketmine\world\World:
+ Collaboration diagram for pocketmine\world\World:

Public Member Functions

 __construct (private Server $server, string $name, private WritableWorldProvider $provider, private AsyncPool $workerPool)
 
 __debugInfo ()
 
 addEntity (Entity $entity)
 
 addOnUnloadCallback (\Closure $callback)
 
 addParticle (Vector3 $pos, Particle $particle, ?array $players=null)
 
 addRandomTickedBlock (Block $block)
 
 addSound (Vector3 $pos, Sound $sound, ?array $players=null)
 
 addTile (Tile $tile)
 
 broadcastPacketToViewers (Vector3 $pos, ClientboundPacket $packet)
 
 cancelUnloadChunkRequest (int $x, int $z)
 
 checkSleep ()
 
 clearCache (bool $force=false)
 
 computeSkyLightReduction ()
 
 computeSunAnglePercentage ()
 
 createBlockUpdatePackets (array $blocks)
 
 doChunkGarbageCollection ()
 
 doTick (int $currentTick)
 
 dropExperience (Vector3 $pos, int $amount)
 
 dropItem (Vector3 $source, Item $item, ?Vector3 $motion=null, int $delay=10)
 
 getAdjacentChunks (int $x, int $z)
 
 getAutoSave ()
 
 getBiome (int $x, int $y, int $z)
 
 getBiomeId (int $x, int $y, int $z)
 
 getBlock (Vector3 $pos, bool $cached=true, bool $addToCache=true)
 
 getBlockAt (int $x, int $y, int $z)
 
 getBlockAt (int $x, int $y, int $z, bool $cached=true, bool $addToCache=true)
 
 getBlockCollisionBoxes (AxisAlignedBB $bb)
 
 getBlockLightAt (int $x, int $y, int $z)
 
 getChunk (int $chunkX, int $chunkZ)
 
 getChunkEntities (int $chunkX, int $chunkZ)
 
 getChunkListeners (int $chunkX, int $chunkZ)
 
 getChunkLoaders (int $chunkX, int $chunkZ)
 
 getChunkPlayers (int $chunkX, int $chunkZ)
 
 getChunkTickRadius ()
 
 getCollidingEntities (AxisAlignedBB $bb, ?Entity $entity=null)
 
 getCollisionBlocks (AxisAlignedBB $bb, bool $targetFirst=false)
 
 getDifficulty ()
 
 getDisplayName ()
 
 getEntities ()
 
 getEntity (int $entityId)
 
 getFolderName ()
 
 getFullLight (Vector3 $pos)
 
 getFullLightAt (int $x, int $y, int $z)
 
 getHighestAdjacentBlockLight (int $x, int $y, int $z)
 
 getHighestAdjacentFullLightAt (int $x, int $y, int $z)
 
 getHighestAdjacentPotentialBlockSkyLight (int $x, int $y, int $z)
 
 getHighestAdjacentPotentialLightAt (int $x, int $y, int $z)
 
 getHighestAdjacentRealBlockSkyLight (int $x, int $y, int $z)
 
 getHighestBlockAt (int $x, int $z)
 
 getId ()
 
 getLoadedChunks ()
 
 getLogger ()
 
 getMaxY ()
 
 getMinY ()
 
 getNearbyEntities (AxisAlignedBB $bb, ?Entity $entity=null)
 
 getNearestEntity (Vector3 $pos, float $maxDistance, string $entityType=Entity::class, bool $includeDead=false)
 
 getOrLoadChunkAtPosition (Vector3 $pos)
 
 getPlayers ()
 
 getPotentialBlockSkyLightAt (int $x, int $y, int $z)
 
 getPotentialLight (Vector3 $pos)
 
 getPotentialLightAt (int $x, int $y, int $z)
 
 getProvider ()
 
 getRandomTickedBlocks ()
 
 getRealBlockSkyLightAt (int $x, int $y, int $z)
 
 getSafeSpawn (?Vector3 $spawn=null)
 
 getSeed ()
 
 getServer ()
 
 getSkyLightReduction ()
 
 getSpawnLocation ()
 
 getSunAngleDegrees ()
 
 getSunAnglePercentage ()
 
 getSunAngleRadians ()
 
 getTickingChunks ()
 
 getTickRateTime ()
 
 getTile (Vector3 $pos)
 
 getTileAt (int $x, int $y, int $z)
 
 getTime ()
 
 getTimeOfDay ()
 
 getViewersForPosition (Vector3 $pos)
 
 isChunkGenerated (int $x, int $z)
 
 isChunkInUse (int $x, int $z)
 
 isChunkLoaded (int $x, int $z)
 
 isChunkLocked (int $chunkX, int $chunkZ)
 
 isChunkPopulated (int $x, int $z)
 
 isDoingTick ()
 
 isInLoadedTerrain (Vector3 $pos)
 
 isInWorld (int $x, int $y, int $z)
 
 isLoaded ()
 
 isSpawnChunk (int $X, int $Z)
 
 loadChunk (int $x, int $z)
 
 lockChunk (int $chunkX, int $chunkZ, ChunkLockId $lockId)
 
 notifyNeighbourBlockUpdate (Vector3 $pos)
 
 onEntityMoved (Entity $entity)
 
 onUnload ()
 
 orderChunkPopulation (int $chunkX, int $chunkZ, ?ChunkLoader $associatedChunkLoader)
 
 registerChunkListener (ChunkListener $listener, int $chunkX, int $chunkZ)
 
 registerChunkLoader (ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad=true)
 
 registerGeneratorToWorker (int $worker)
 
 registerTickingChunk (ChunkTicker $ticker, int $chunkX, int $chunkZ)
 
 removeEntity (Entity $entity)
 
 removeOnUnloadCallback (\Closure $callback)
 
 removeRandomTickedBlock (Block $block)
 
 removeTile (Tile $tile)
 
 requestChunkPopulation (int $chunkX, int $chunkZ, ?ChunkLoader $associatedChunkLoader)
 
 requestSafeSpawn (?Vector3 $spawn=null)
 
 save (bool $force=false)
 
 saveChunks ()
 
 scheduleDelayedBlockUpdate (Vector3 $pos, int $delay)
 
 sendTime (Player ... $targets)
 
 setAutoSave (bool $value)
 
 setBiomeId (int $x, int $y, int $z, int $biomeId)
 
 setBlock (Vector3 $pos, Block $block, bool $update=true)
 
 setBlockAt (int $x, int $y, int $z, Block $block)
 
 setBlockAt (int $x, int $y, int $z, Block $block, bool $update=true)
 
 setChunk (int $chunkX, int $chunkZ, Chunk $chunk)
 
 setChunkTickRadius (int $radius)
 
 setDifficulty (int $difficulty)
 
 setDisplayName (string $name)
 
 setSleepTicks (int $ticks)
 
 setSpawnLocation (Vector3 $pos)
 
 setTime (int $time)
 
 startTime ()
 
 stopTime ()
 
 unloadChunk (int $x, int $z, bool $safe=true, bool $trySave=true)
 
 unloadChunkRequest (int $x, int $z, bool $safe=true)
 
 unloadChunks (bool $force=false)
 
 unlockChunk (int $chunkX, int $chunkZ, ?ChunkLockId $lockId)
 
 unregisterChunkListener (ChunkListener $listener, int $chunkX, int $chunkZ)
 
 unregisterChunkListenerFromAll (ChunkListener $listener)
 
 unregisterChunkLoader (ChunkLoader $loader, int $chunkX, int $chunkZ)
 
 unregisterGenerator ()
 
 unregisterTickingChunk (ChunkTicker $ticker, int $chunkX, int $chunkZ)
 
 updateAllLight (int $x, int $y, int $z)
 
 useBreakOn (Vector3 $vector, ?Item &$item=null, ?Player $player=null, bool $createParticles=false, array &$returnedItems=[])
 
 useItemOn (Vector3 $vector, Item &$item, int $face, ?Vector3 $clickVector=null, ?Player $player=null, bool $playSound=false, array &$returnedItems=[])
 

Static Public Member Functions

static blockHash (int $x, int $y, int $z)
 
static chunkBlockHash (int $x, int $y, int $z)
 
static chunkHash (int $x, int $z)
 
static getBlockXYZ (int $hash, ?int &$x, ?int &$y, ?int &$z)
 
static getDifficultyFromString (string $str)
 
static getXZ (int $hash, ?int &$x, ?int &$z)
 

Public Attributes

bool $stopTime = false
 
float $tickRateTime = 0
 
WorldTimings $timings
 
array $updateEntities = []
 
const DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK = 3
 
const DIFFICULTY_EASY = 1
 
const DIFFICULTY_HARD = 3
 
const DIFFICULTY_NORMAL = 2
 
const DIFFICULTY_PEACEFUL = 0
 
const TIME_DAY = 1000
 
const TIME_FULL = 24000
 
const TIME_MIDNIGHT = 18000
 
const TIME_NIGHT = 13000
 
const TIME_NOON = 6000
 
const TIME_SUNRISE = 23000
 
const TIME_SUNSET = 12000
 
const Y_MAX = 320
 
const Y_MIN = -64
 

Protected Member Functions

 actuallyDoTick (int $currentTick)
 

Detailed Description

@phpstan-type ChunkPosHash int @phpstan-type BlockPosHash int @phpstan-type ChunkBlockPosHash int

Definition at line 148 of file World.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\world\World::__construct ( private Server $server,
string $name,
private WritableWorldProvider $provider,
private AsyncPool $workerPool )

Init the default world data

Definition at line 479 of file World.php.

References pocketmine\scheduler\AsyncPool\removeWorkerStartHook(), and pocketmine\server().

+ Here is the call graph for this function:

Member Function Documentation

◆ __debugInfo()

pocketmine\world\World::__debugInfo ( )
Returns
mixed[]

Definition at line 1426 of file World.php.

◆ actuallyDoTick()

pocketmine\world\World::actuallyDoTick ( int $currentTick)
protected

Definition at line 934 of file World.php.

◆ addEntity()

pocketmine\world\World::addEntity ( Entity $entity)
Exceptions

InvalidArgumentException

Definition at line 2670 of file World.php.

◆ addOnUnloadCallback()

pocketmine\world\World::addOnUnloadCallback ( \Closure $callback)

@phpstan-param \Closure() : void $callback

Definition at line 668 of file World.php.

◆ addParticle()

pocketmine\world\World::addParticle ( Vector3 $pos,
Particle $particle,
?array $players = null )
Parameters
Player[] | null$players

Definition at line 730 of file World.php.

◆ addRandomTickedBlock()

pocketmine\world\World::addRandomTickedBlock ( Block $block)

Definition at line 1192 of file World.php.

◆ addSound()

pocketmine\world\World::addSound ( Vector3 $pos,
Sound $sound,
?array $players = null )
Parameters
Player[] | null$players

Definition at line 701 of file World.php.

◆ addTile()

pocketmine\world\World::addTile ( Tile $tile)

Definition at line 2774 of file World.php.

◆ blockHash()

static pocketmine\world\World::blockHash ( int $x,
int $y,
int $z )
static

@phpstan-return BlockPosHash

Definition at line 400 of file World.php.

◆ broadcastPacketToViewers()

pocketmine\world\World::broadcastPacketToViewers ( Vector3 $pos,
ClientboundPacket $packet )

Broadcasts a packet to every player who has the target position within their view distance.

Definition at line 800 of file World.php.

◆ cancelUnloadChunkRequest()

pocketmine\world\World::cancelUnloadChunkRequest ( int $x,
int $z )

Definition at line 2966 of file World.php.

◆ checkSleep()

pocketmine\world\World::checkSleep ( )

Definition at line 1060 of file World.php.

◆ chunkBlockHash()

static pocketmine\world\World::chunkBlockHash ( int $x,
int $y,
int $z )
static

Computes a small index relative to chunk base from the given coordinates.

Definition at line 420 of file World.php.

◆ chunkHash()

static pocketmine\world\World::chunkHash ( int $x,
int $z )
static

@phpstan-return ChunkPosHash

Definition at line 381 of file World.php.

◆ clearCache()

pocketmine\world\World::clearCache ( bool $force = false)

Definition at line 1142 of file World.php.

◆ computeSkyLightReduction()

pocketmine\world\World::computeSkyLightReduction ( )

Computes how many points of sky light is subtracted based on the current time. Used to offset raw chunk sky light to get a real light value.

Definition at line 1659 of file World.php.

◆ computeSunAnglePercentage()

pocketmine\world\World::computeSunAnglePercentage ( )

Computes the percentage of a circle away from noon the sun is currently at. This can be multiplied by 2 * M_PI to get an angle in radians, or by 360 to get an angle in degrees.

Definition at line 1621 of file World.php.

◆ createBlockUpdatePackets()

pocketmine\world\World::createBlockUpdatePackets ( array $blocks)
Parameters
Vector3[]$blocks
Returns
ClientboundPacket[] @phpstan-return list<ClientboundPacket>

Definition at line 1096 of file World.php.

◆ doChunkGarbageCollection()

pocketmine\world\World::doChunkGarbageCollection ( )

Definition at line 3494 of file World.php.

◆ doTick()

pocketmine\world\World::doTick ( int $currentTick)

Definition at line 919 of file World.php.

◆ dropExperience()

pocketmine\world\World::dropExperience ( Vector3 $pos,
int $amount )

Drops XP orbs into the world for the specified amount, splitting the amount into several orbs if necessary.

Returns
ExperienceOrb[] @phpstan-return list<ExperienceOrb>

Definition at line 2023 of file World.php.

◆ dropItem()

pocketmine\world\World::dropItem ( Vector3 $source,
Item $item,
?Vector3 $motion = null,
int $delay = 10 )

Definition at line 2003 of file World.php.

◆ getAdjacentChunks()

pocketmine\world\World::getAdjacentChunks ( int $x,
int $z )

Returns the chunks adjacent to the specified chunk.

Returns
Chunk[]|null[] chunkHash => Chunk|null @phpstan-return array<ChunkPosHash, Chunk|null>

Definition at line 2481 of file World.php.

◆ getAutoSave()

pocketmine\world\World::getAutoSave ( )

Definition at line 756 of file World.php.

◆ getBiome()

pocketmine\world\World::getBiome ( int $x,
int $y,
int $z )

Definition at line 2432 of file World.php.

◆ getBiomeId()

pocketmine\world\World::getBiomeId ( int $x,
int $y,
int $z )

Definition at line 2425 of file World.php.

◆ getBlock()

pocketmine\world\World::getBlock ( Vector3 $pos,
bool $cached = true,
bool $addToCache = true )

Gets the Block object at the Vector3 location. This method wraps around getBlockAt, converting the vector components to integers.

Note: If you're using this for performance-sensitive code, and you're guaranteed to be supplying ints in the specified vector, consider using getBlockAt instead for better performance.

Parameters
bool$cachedWhether to use the block cache for getting the block (faster, but may be inaccurate)
bool$addToCacheWhether to cache the block object created by this method call.

Definition at line 1872 of file World.php.

◆ getBlockAt() [1/2]

pocketmine\world\ChunkManager::getBlockAt ( int $x,
int $y,
int $z )
inherited

Returns a Block object representing the block state at the given coordinates.

Implemented in pocketmine\world\SimpleChunkManager.

◆ getBlockAt() [2/2]

pocketmine\world\World::getBlockAt ( int $x,
int $y,
int $z,
bool $cached = true,
bool $addToCache = true )

Gets the Block object at the specified coordinates.

Note for plugin developers: If you are using this method a lot (thousands of times for many positions for example), you may want to set addToCache to false to avoid using excessive amounts of memory.

Parameters
bool$cachedWhether to use the block cache for getting the block (faster, but may be inaccurate)
bool$addToCacheWhether to cache the block object created by this method call.

Definition at line 1885 of file World.php.

◆ getBlockCollisionBoxes()

pocketmine\world\World::getBlockCollisionBoxes ( AxisAlignedBB $bb)
Returns
AxisAlignedBB[] @phpstan-return list<AxisAlignedBB>

Definition at line 1587 of file World.php.

◆ getBlockLightAt()

pocketmine\world\World::getBlockLightAt ( int $x,
int $y,
int $z )

Gets the raw block light level

Returns
int 0-15

Definition at line 1764 of file World.php.

◆ getBlockXYZ()

static pocketmine\world\World::getBlockXYZ ( int $hash,
?int & $x,
?int & $y,
?int & $z )
static

@phpstan-param BlockPosHash $hash @phpstan-param-out int $x @phpstan-param-out int $y @phpstan-param-out int $z

Definition at line 430 of file World.php.

◆ getChunk()

pocketmine\world\World::getChunk ( int $chunkX,
int $chunkZ )

Implements pocketmine\world\ChunkManager.

Definition at line 2456 of file World.php.

◆ getChunkEntities()

pocketmine\world\World::getChunkEntities ( int $chunkX,
int $chunkZ )
Returns
Entity[] entity runtime ID => Entity @phpstan-return array<int, Entity>

Definition at line 2464 of file World.php.

◆ getChunkListeners()

pocketmine\world\World::getChunkListeners ( int $chunkX,
int $chunkZ )

Returns all the listeners attached to this chunk.

Returns
ChunkListener[] @phpstan-return array<int, ChunkListener>

Definition at line 896 of file World.php.

◆ getChunkLoaders()

pocketmine\world\World::getChunkLoaders ( int $chunkX,
int $chunkZ )

Gets the chunk loaders being used in a specific chunk

Returns
ChunkLoader[] @phpstan-return array<int, ChunkLoader>

Definition at line 783 of file World.php.

◆ getChunkPlayers()

pocketmine\world\World::getChunkPlayers ( int $chunkX,
int $chunkZ )
Deprecated
WARNING: This function has a misleading name. Contrary to what the name might imply, this function DOES NOT return players who are IN a chunk, rather, it returns players who can SEE the chunk.

Returns a list of players who have the target chunk within their view distance.

Returns
Player[] spl_object_id => Player @phpstan-return array<int, Player>

Definition at line 773 of file World.php.

◆ getChunkTickRadius()

pocketmine\world\World::getChunkTickRadius ( )

Returns the radius of chunks to be ticked around each player. This is referred to as "simulation distance" in the Minecraft: Bedrock world options screen.

Definition at line 1207 of file World.php.

◆ getCollidingEntities()

pocketmine\world\World::getCollidingEntities ( AxisAlignedBB $bb,
?Entity $entity = null )

Returns all collidable entities whose bounding boxes intersect the given bounding box. If an entity is given, it will be excluded from the result. If a non-collidable entity is given, the result will be empty.

This function is the same as World::getNearbyEntities(), but with additional collidability filters.

Returns
Entity[] @phpstan-return array<int, Entity>

Definition at line 2314 of file World.php.

◆ getCollisionBlocks()

pocketmine\world\World::getCollisionBlocks ( AxisAlignedBB $bb,
bool $targetFirst = false )
Returns
Block[] @phpstan-return list<Block>

Definition at line 1521 of file World.php.

◆ getDifficulty()

pocketmine\world\World::getDifficulty ( )

Definition at line 3209 of file World.php.

◆ getDifficultyFromString()

static pocketmine\world\World::getDifficultyFromString ( string $str)
static

Definition at line 450 of file World.php.

◆ getDisplayName()

pocketmine\world\World::getDisplayName ( )

Returns the World display name. WARNING: This is NOT guaranteed to be unique. Multiple worlds at runtime may share the same display name.

Definition at line 3149 of file World.php.

◆ getEntities()

pocketmine\world\World::getEntities ( )

Returns a list of all the entities in this world, indexed by their entity runtime IDs

Returns
Entity[] @phpstan-return array<int, Entity>

Definition at line 2300 of file World.php.

◆ getEntity()

pocketmine\world\World::getEntity ( int $entityId)

Definition at line 2290 of file World.php.

◆ getFolderName()

pocketmine\world\World::getFolderName ( )

Returns the World folder name. This will not change at runtime and will be unique to a world per runtime.

Definition at line 3166 of file World.php.

◆ getFullLight()

pocketmine\world\World::getFullLight ( Vector3 $pos)

Returns the highest level of any type of light at the given coordinates, adjusted for the current weather and time of day.

Definition at line 1678 of file World.php.

◆ getFullLightAt()

pocketmine\world\World::getFullLightAt ( int $x,
int $y,
int $z )

Returns the highest level of any type of light at the given coordinates, adjusted for the current weather and time of day.

Definition at line 1689 of file World.php.

◆ getHighestAdjacentBlockLight()

pocketmine\world\World::getHighestAdjacentBlockLight ( int $x,
int $y,
int $z )

Returns the highest block light level available in the positions adjacent to the specified block coordinates.

Definition at line 1834 of file World.php.

◆ getHighestAdjacentFullLightAt()

pocketmine\world\World::getHighestAdjacentFullLightAt ( int $x,
int $y,
int $z )

Returns the highest level of any type of light at, or adjacent to, the given coordinates, adjusted for the current weather and time of day.

Definition at line 1702 of file World.php.

◆ getHighestAdjacentPotentialBlockSkyLight()

pocketmine\world\World::getHighestAdjacentPotentialBlockSkyLight ( int $x,
int $y,
int $z )

Returns the highest potential level of sky light in the positions adjacent to the specified block coordinates.

Definition at line 1819 of file World.php.

◆ getHighestAdjacentPotentialLightAt()

pocketmine\world\World::getHighestAdjacentPotentialLightAt ( int $x,
int $y,
int $z )

Returns the highest potential level of any type of light at, or adjacent to, the given coordinates. This is not affected by weather or time of day.

Definition at line 1729 of file World.php.

◆ getHighestAdjacentRealBlockSkyLight()

pocketmine\world\World::getHighestAdjacentRealBlockSkyLight ( int $x,
int $y,
int $z )

Returns the highest block sky light available in the positions adjacent to the given coordinates, adjusted for the world's current time of day and weather conditions.

Definition at line 1827 of file World.php.

◆ getHighestBlockAt()

pocketmine\world\World::getHighestBlockAt ( int $x,
int $z )

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

Returns
int|null 0-255, or null if the column is empty
Exceptions
WorldExceptionif the terrain is not generated

Definition at line 2619 of file World.php.

References pocketmine\world\format\Chunk\getHighestBlockAt().

+ Here is the call graph for this function:

◆ getId()

pocketmine\world\World::getId ( )
final

Returns the unique world identifier

Definition at line 615 of file World.php.

Referenced by pocketmine\world\generator\GeneratorRegisterTask\__construct().

+ Here is the caller graph for this function:

◆ getLoadedChunks()

pocketmine\world\World::getLoadedChunks ( )
Returns
Chunk[] chunkHash => Chunk @phpstan-return array<ChunkPosHash, Chunk>

Definition at line 2452 of file World.php.

◆ getLogger()

pocketmine\world\World::getLogger ( )

Definition at line 604 of file World.php.

◆ getMaxY()

pocketmine\world\World::getMaxY ( )

Returns the highest buildable Y coordinate of the world

Implements pocketmine\world\ChunkManager.

Definition at line 3205 of file World.php.

Referenced by pocketmine\world\generator\GeneratorRegisterTask\__construct().

+ Here is the caller graph for this function:

◆ getMinY()

pocketmine\world\World::getMinY ( )

Returns the lowest buildable Y coordinate of the world

Implements pocketmine\world\ChunkManager.

Definition at line 3201 of file World.php.

Referenced by pocketmine\world\generator\GeneratorRegisterTask\__construct().

+ Here is the caller graph for this function:

◆ getNearbyEntities()

pocketmine\world\World::getNearbyEntities ( AxisAlignedBB $bb,
?Entity $entity = null )

Returns all entities whose bounding boxes intersect the given bounding box, excluding the given entity.

Returns
Entity[] @phpstan-return array<int, Entity>

Definition at line 2332 of file World.php.

◆ getNearestEntity()

pocketmine\world\World::getNearestEntity ( Vector3 $pos,
float $maxDistance,
string $entityType = Entity::class,
bool $includeDead = false )

Returns the closest Entity to the specified position, within the given radius.

Parameters
string$entityTypeClass of entity to use for instanceof
bool$includeDeadWhether to include entitites which are dead @phpstan-template TEntity of Entity @phpstan-param class-string<TEntity> $entityType
Returns
Entity|null an entity of type $entityType, or null if not found @phpstan-return TEntity

Definition at line 2364 of file World.php.

◆ getOrLoadChunkAtPosition()

pocketmine\world\World::getOrLoadChunkAtPosition ( Vector3 $pos)

Returns the chunk containing the given Vector3 position.

Definition at line 2471 of file World.php.

◆ getPlayers()

pocketmine\world\World::getPlayers ( )

Returns a list of the players in this world

Returns
Player[] entity runtime ID => Player @phpstan-return array<int, Player>

Definition at line 2404 of file World.php.

◆ getPotentialBlockSkyLightAt()

pocketmine\world\World::getPotentialBlockSkyLightAt ( int $x,
int $y,
int $z )

Returns the highest potential level of sky light at the target coordinates, regardless of the time of day or weather conditions.

Returns
int 0-15

Definition at line 1739 of file World.php.

◆ getPotentialLight()

pocketmine\world\World::getPotentialLight ( Vector3 $pos)

Returns the highest potential level of any type of light at the target coordinates. This is not affected by weather or time of day.

Definition at line 1710 of file World.php.

◆ getPotentialLightAt()

pocketmine\world\World::getPotentialLightAt ( int $x,
int $y,
int $z )

Returns the highest potential level of any type of light at the target coordinates. This is not affected by weather or time of day.

Definition at line 1721 of file World.php.

◆ getProvider()

pocketmine\world\World::getProvider ( )
final

Definition at line 608 of file World.php.

◆ getRandomTickedBlocks()

pocketmine\world\World::getRandomTickedBlocks ( )
Returns
true[] fullID => dummy @phpstan-return array<int, true>

Definition at line 1188 of file World.php.

◆ getRealBlockSkyLightAt()

pocketmine\world\World::getRealBlockSkyLightAt ( int $x,
int $y,
int $z )

Returns the sky light level at the specified coordinates, offset by the current time and weather.

Returns
int 0-15

Definition at line 1754 of file World.php.

◆ getSafeSpawn()

pocketmine\world\World::getSafeSpawn ( ?Vector3 $spawn = null)

Returns a safe spawn position near the given position, or near the world's spawn position if not provided. This function will throw an exception if the terrain is not already generated in advance.

Exceptions
WorldExceptionif the terrain is not generated

Definition at line 3092 of file World.php.

◆ getSeed()

pocketmine\world\World::getSeed ( )

Gets the world seed

Definition at line 3197 of file World.php.

Referenced by pocketmine\world\generator\GeneratorRegisterTask\__construct().

+ Here is the caller graph for this function:

◆ getServer()

pocketmine\world\World::getServer ( )

Definition at line 600 of file World.php.

◆ getSkyLightReduction()

pocketmine\world\World::getSkyLightReduction ( )

Returns how many points of sky light is subtracted based on the current time.

Definition at line 1670 of file World.php.

◆ getSpawnLocation()

pocketmine\world\World::getSpawnLocation ( )

Returns a Position pointing to the spawn

Definition at line 2649 of file World.php.

◆ getSunAngleDegrees()

pocketmine\world\World::getSunAngleDegrees ( )

Returns the current sun angle in degrees.

Definition at line 1651 of file World.php.

◆ getSunAnglePercentage()

pocketmine\world\World::getSunAnglePercentage ( )

Returns the percentage of a circle away from noon the sun is currently at.

Definition at line 1637 of file World.php.

◆ getSunAngleRadians()

pocketmine\world\World::getSunAngleRadians ( )

Returns the current sun angle in radians.

Definition at line 1644 of file World.php.

◆ getTickingChunks()

pocketmine\world\World::getTickingChunks ( )

Returns a list of chunk position hashes (as returned by World::chunkHash()) which are currently valid for ticking.

Returns
int[] @phpstan-return list<ChunkPosHash>

Definition at line 1226 of file World.php.

◆ getTickRateTime()

pocketmine\world\World::getTickRateTime ( )

Definition at line 581 of file World.php.

◆ getTile()

pocketmine\world\World::getTile ( Vector3 $pos)

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

Note: This method wraps getTileAt(). If you're guaranteed to be passing integers, and you're using this method in performance-sensitive code, consider using getTileAt() instead of this method for better performance.

Definition at line 2414 of file World.php.

◆ getTileAt()

pocketmine\world\World::getTileAt ( int $x,
int $y,
int $z )

Returns the tile at the specified x,y,z coordinates, or null if it does not exist.

Definition at line 2421 of file World.php.

◆ getTime()

pocketmine\world\World::getTime ( )

Gets the current time

Definition at line 3134 of file World.php.

◆ getTimeOfDay()

pocketmine\world\World::getTimeOfDay ( )

Returns the current time of day

Definition at line 3141 of file World.php.

◆ getViewersForPosition()

pocketmine\world\World::getViewersForPosition ( Vector3 $pos)

Returns an array of players who have the target position within their view distance.

Returns
Player[] spl_object_id => Player @phpstan-return array<int, Player>

Definition at line 793 of file World.php.

◆ getXZ()

static pocketmine\world\World::getXZ ( int $hash,
?int & $x,
?int & $z )
static

@phpstan-param ChunkPosHash $hash @phpstan-param-out int $x @phpstan-param-out int $z

Definition at line 446 of file World.php.

◆ isChunkGenerated()

pocketmine\world\World::isChunkGenerated ( int $x,
int $z )

Definition at line 2637 of file World.php.

◆ isChunkInUse()

pocketmine\world\World::isChunkInUse ( int $x,
int $z )

Definition at line 2820 of file World.php.

◆ isChunkLoaded()

pocketmine\world\World::isChunkLoaded ( int $x,
int $z )

Definition at line 2633 of file World.php.

◆ isChunkLocked()

pocketmine\world\World::isChunkLocked ( int $chunkX,
int $chunkZ )

Returns whether anyone currently has a lock on the chunk at the given coordinates. You should check this to make sure that population tasks aren't currently modifying chunks that you want to use in async tasks.

Definition at line 2541 of file World.php.

◆ isChunkPopulated()

pocketmine\world\World::isChunkPopulated ( int $x,
int $z )

Definition at line 2641 of file World.php.

◆ isDoingTick()

pocketmine\world\World::isDoingTick ( )

Definition at line 912 of file World.php.

◆ isInLoadedTerrain()

pocketmine\world\World::isInLoadedTerrain ( Vector3 $pos)

Returns whether the given position is in a loaded area of terrain.

Definition at line 2629 of file World.php.

◆ isInWorld()

pocketmine\world\World::isInWorld ( int $x,
int $y,
int $z )

Returns whether the specified coordinates are within the valid world boundaries, taking world format limitations into account.

Implements pocketmine\world\ChunkManager.

Definition at line 1854 of file World.php.

◆ isLoaded()

pocketmine\world\World::isLoaded ( )

Definition at line 619 of file World.php.

◆ isSpawnChunk()

pocketmine\world\World::isSpawnChunk ( int $X,
int $Z )

Returns whether the chunk at the specified coordinates is a spawn chunk

Definition at line 3050 of file World.php.

◆ loadChunk()

pocketmine\world\World::loadChunk ( int $x,
int $z )

Attempts to load a chunk from the world provider (if not already loaded). If the chunk is already loaded, it is returned directly.

Returns
Chunk|null the requested chunk, or null on failure.

Definition at line 2830 of file World.php.

◆ lockChunk()

pocketmine\world\World::lockChunk ( int $chunkX,
int $chunkZ,
ChunkLockId $lockId )

Flags a chunk as locked, usually for async modification.

This is an advisory lock. This means that the lock does not prevent the chunk from being modified on the main thread, such as by setBlock() or setBiomeId(). However, you can use it to detect when such modifications have taken place - unlockChunk() with the same lockID will fail and return false if this happens.

This is used internally by the generation system to ensure that two PopulationTasks don't try to modify the same chunk at the same time. Generation will respect these locks and won't try to do generation of chunks over which a lock is held.

WARNING: Be sure to release all locks once you're done with them, or you WILL have problems with terrain not being generated.

Definition at line 2509 of file World.php.

◆ notifyNeighbourBlockUpdate()

pocketmine\world\World::notifyNeighbourBlockUpdate ( Vector3 $pos)

Notify the blocks at and around the position that the block at the position may have changed. This will cause onNearbyBlockChange() to be called for these blocks. TODO: Accept plain integers in PM6 - the Vector3 requirement is an unnecessary inconvenience

See also
Block::onNearbyBlockChange()

Definition at line 1513 of file World.php.

◆ onEntityMoved()

pocketmine\world\World::onEntityMoved ( Entity $entity)

Definition at line 2729 of file World.php.

◆ onUnload()

pocketmine\world\World::onUnload ( )

Definition at line 626 of file World.php.

◆ orderChunkPopulation()

pocketmine\world\World::orderChunkPopulation ( int $chunkX,
int $chunkZ,
?ChunkLoader $associatedChunkLoader )

Initiates asynchronous generation/population of the target chunk, if it's not already generated/populated. If generation has already been requested for the target chunk, the promise for the already active request will be returned directly.

If the chunk is currently locked (for example due to another chunk using it for async generation), the request will be queued and executed at the earliest opportunity.

@phpstan-return Promise<Chunk>

Definition at line 3336 of file World.php.

◆ registerChunkListener()

pocketmine\world\World::registerChunkListener ( ChunkListener $listener,
int $chunkX,
int $chunkZ )

Registers a listener to receive events on a chunk.

Definition at line 850 of file World.php.

◆ registerChunkLoader()

pocketmine\world\World::registerChunkLoader ( ChunkLoader $loader,
int $chunkX,
int $chunkZ,
bool $autoLoad = true )

Definition at line 812 of file World.php.

◆ registerGeneratorToWorker()

pocketmine\world\World::registerGeneratorToWorker ( int $worker)

Definition at line 585 of file World.php.

◆ registerTickingChunk()

pocketmine\world\World::registerTickingChunk ( ChunkTicker $ticker,
int $chunkX,
int $chunkZ )

Instructs the World to tick the specified chunk, for as long as this chunk ticker (or any other chunk ticker) is registered to it.

Definition at line 1234 of file World.php.

◆ removeEntity()

pocketmine\world\World::removeEntity ( Entity $entity)

Removes the entity from the world index

Exceptions

InvalidArgumentException

Definition at line 2699 of file World.php.

◆ removeOnUnloadCallback()

pocketmine\world\World::removeOnUnloadCallback ( \Closure $callback)

@phpstan-param \Closure() : void $callback

Definition at line 673 of file World.php.

◆ removeRandomTickedBlock()

pocketmine\world\World::removeRandomTickedBlock ( Block $block)

Definition at line 1199 of file World.php.

◆ removeTile()

pocketmine\world\World::removeTile ( Tile $tile)

Definition at line 2803 of file World.php.

◆ requestChunkPopulation()

pocketmine\world\World::requestChunkPopulation ( int $chunkX,
int $chunkZ,
?ChunkLoader $associatedChunkLoader )

Attempts to initiate asynchronous generation/population of the target chunk, if it's currently reasonable to do so (and if it isn't already generated/populated). If the generator is busy, the request will be put into a queue and delayed until a better time.

A ChunkLoader can be associated with the generation request to ensure that the generation request is cancelled if no loaders are attached to the target chunk. If no loader is provided, one will be assigned (and automatically removed when the generation request completes).

@phpstan-return Promise<Chunk>

Definition at line 3313 of file World.php.

◆ requestSafeSpawn()

pocketmine\world\World::requestSafeSpawn ( ?Vector3 $spawn = null)

Requests a safe spawn position near the given position, or near the world's spawn position if not provided. Terrain near the position will be loaded or generated as needed.

Returns
Promise Resolved to a Position object, or rejected if the world is unloaded. @phpstan-return Promise<Position>

Definition at line 3065 of file World.php.

◆ save()

pocketmine\world\World::save ( bool $force = false)

Definition at line 1430 of file World.php.

◆ saveChunks()

pocketmine\world\World::saveChunks ( )

Definition at line 1450 of file World.php.

◆ scheduleDelayedBlockUpdate()

pocketmine\world\World::scheduleDelayedBlockUpdate ( Vector3 $pos,
int $delay )

Schedules a block update to be executed after the specified number of ticks. Blocks will be updated with the scheduled update type.

Definition at line 1472 of file World.php.

◆ sendTime()

pocketmine\world\World::sendTime ( Player ... $targets)

Definition at line 903 of file World.php.

◆ setAutoSave()

pocketmine\world\World::setAutoSave ( bool $value)

Definition at line 760 of file World.php.

◆ setBiomeId()

pocketmine\world\World::setBiomeId ( int $x,
int $y,
int $z,
int $biomeId )

Definition at line 2436 of file World.php.

◆ setBlock()

pocketmine\world\World::setBlock ( Vector3 $pos,
Block $block,
bool $update = true )

Sets the block at the given Vector3 coordinates.

Exceptions

InvalidArgumentException if the position is out of the world bounds

Definition at line 1940 of file World.php.

◆ setBlockAt() [1/2]

pocketmine\world\ChunkManager::setBlockAt ( int $x,
int $y,
int $z,
Block $block )
inherited

Sets the block at the given coordinates to the block state specified.

Exceptions

InvalidArgumentException

Implemented in pocketmine\world\SimpleChunkManager.

◆ setBlockAt() [2/2]

pocketmine\world\World::setBlockAt ( int $x,
int $y,
int $z,
Block $block,
bool $update = true )

Sets the block at the given coordinates.

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

Exceptions

InvalidArgumentException if the position is out of the world bounds

Definition at line 1952 of file World.php.

◆ setChunk()

pocketmine\world\World::setChunk ( int $chunkX,
int $chunkZ,
Chunk $chunk )

Implements pocketmine\world\ChunkManager.

Definition at line 2545 of file World.php.

◆ setChunkTickRadius()

pocketmine\world\World::setChunkTickRadius ( int $radius)

Sets the radius of chunks ticked around each player. This may not take effect immediately, since each player needs to recalculate their tick radius.

Definition at line 1215 of file World.php.

◆ setDifficulty()

pocketmine\world\World::setDifficulty ( int $difficulty)

Definition at line 3213 of file World.php.

◆ setDisplayName()

pocketmine\world\World::setDisplayName ( string $name)

Sets the World display name.

Definition at line 3156 of file World.php.

◆ setSleepTicks()

pocketmine\world\World::setSleepTicks ( int $ticks)

Definition at line 1086 of file World.php.

◆ setSpawnLocation()

pocketmine\world\World::setSpawnLocation ( Vector3 $pos)

Sets the world spawn location

Definition at line 2656 of file World.php.

◆ setTime()

pocketmine\world\World::setTime ( int $time)

Sets the current time on the world

Definition at line 3173 of file World.php.

◆ startTime()

pocketmine\world\World::startTime ( )

Start the time again, if it was stopped

Definition at line 3189 of file World.php.

◆ stopTime()

pocketmine\world\World::stopTime ( )

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

Definition at line 3181 of file World.php.

◆ unloadChunk()

pocketmine\world\World::unloadChunk ( int $x,
int $z,
bool $safe = true,
bool $trySave = true )

Definition at line 2970 of file World.php.

◆ unloadChunkRequest()

pocketmine\world\World::unloadChunkRequest ( int $x,
int $z,
bool $safe = true )

Definition at line 2956 of file World.php.

◆ unloadChunks()

pocketmine\world\World::unloadChunks ( bool $force = false)

Definition at line 3512 of file World.php.

◆ unlockChunk()

pocketmine\world\World::unlockChunk ( int $chunkX,
int $chunkZ,
?ChunkLockId $lockId )

Unlocks a chunk previously locked by lockChunk().

You must provide the same lockID as provided to lockChunk(). If a null lockID is given, any existing lock will be removed from the chunk, regardless of who owns it.

Returns true if unlocking was successful, false otherwise.

Definition at line 2526 of file World.php.

◆ unregisterChunkListener()

pocketmine\world\World::unregisterChunkListener ( ChunkListener $listener,
int $chunkX,
int $chunkZ )

Unregisters a chunk listener previously registered.

See also
World::registerChunkListener()

Definition at line 867 of file World.php.

◆ unregisterChunkListenerFromAll()

pocketmine\world\World::unregisterChunkListenerFromAll ( ChunkListener $listener)

Unregisters a chunk listener from all chunks it is listening on in this World.

Definition at line 883 of file World.php.

◆ unregisterChunkLoader()

pocketmine\world\World::unregisterChunkLoader ( ChunkLoader $loader,
int $chunkX,
int $chunkZ )

Definition at line 830 of file World.php.

◆ unregisterGenerator()

pocketmine\world\World::unregisterGenerator ( )

Definition at line 591 of file World.php.

◆ unregisterTickingChunk()

pocketmine\world\World::unregisterTickingChunk ( ChunkTicker $ticker,
int $chunkX,
int $chunkZ )

Unregisters the given chunk ticker from the specified chunk. If there are other tickers still registered to the chunk, it will continue to be ticked.

Definition at line 1244 of file World.php.

◆ updateAllLight()

pocketmine\world\World::updateAllLight ( int $x,
int $y,
int $z )

Definition at line 1774 of file World.php.

◆ useBreakOn()

pocketmine\world\World::useBreakOn ( Vector3 $vector,
?Item & $item = null,
?Player $player = null,
bool $createParticles = false,
array & $returnedItems = [] )

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
Item&$itemreference parameter (if null, can break anything)
Item[]&$returnedItemsItems to be added to the target's inventory (or dropped, if the inventory is full) @phpstan-param-out Item $item

Definition at line 2046 of file World.php.

◆ useItemOn()

pocketmine\world\World::useItemOn ( Vector3 $vector,
Item & $item,
int $face,
?Vector3 $clickVector = null,
?Player $player = null,
bool $playSound = false,
array & $returnedItems = [] )

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

Parameters
Player | null$playerdefault null
bool$playSoundWhether to play a block-place sound if the block was placed successfully.
Item[]&$returnedItemsItems to be added to the target's inventory (or dropped if the inventory is full)

Definition at line 2152 of file World.php.

Member Data Documentation

◆ $stopTime

bool pocketmine\world\World::$stopTime = false

Definition at line 276 of file World.php.

◆ $tickRateTime

float pocketmine\world\World::$tickRateTime = 0

Definition at line 359 of file World.php.

◆ $timings

WorldTimings pocketmine\world\World::$timings

Definition at line 357 of file World.php.

◆ $updateEntities

array pocketmine\world\World::$updateEntities = []

Definition at line 201 of file World.php.

◆ DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK

const pocketmine\world\World::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK = 3

Definition at line 169 of file World.php.

◆ DIFFICULTY_EASY

const pocketmine\world\World::DIFFICULTY_EASY = 1

Definition at line 165 of file World.php.

◆ DIFFICULTY_HARD

const pocketmine\world\World::DIFFICULTY_HARD = 3

Definition at line 167 of file World.php.

◆ DIFFICULTY_NORMAL

const pocketmine\world\World::DIFFICULTY_NORMAL = 2

Definition at line 166 of file World.php.

◆ DIFFICULTY_PEACEFUL

const pocketmine\world\World::DIFFICULTY_PEACEFUL = 0

Definition at line 164 of file World.php.

◆ TIME_DAY

const pocketmine\world\World::TIME_DAY = 1000

Definition at line 155 of file World.php.

◆ TIME_FULL

const pocketmine\world\World::TIME_FULL = 24000

Definition at line 162 of file World.php.

◆ TIME_MIDNIGHT

const pocketmine\world\World::TIME_MIDNIGHT = 18000

Definition at line 159 of file World.php.

◆ TIME_NIGHT

const pocketmine\world\World::TIME_NIGHT = 13000

Definition at line 158 of file World.php.

◆ TIME_NOON

const pocketmine\world\World::TIME_NOON = 6000

Definition at line 156 of file World.php.

◆ TIME_SUNRISE

const pocketmine\world\World::TIME_SUNRISE = 23000

Definition at line 160 of file World.php.

◆ TIME_SUNSET

const pocketmine\world\World::TIME_SUNSET = 12000

Definition at line 157 of file World.php.

◆ Y_MAX

const pocketmine\world\World::Y_MAX = 320

Definition at line 152 of file World.php.

◆ Y_MIN

const pocketmine\world\World::Y_MIN = -64

Definition at line 153 of file World.php.


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