PocketMine-MP 5.19.1 git-5cc1068cd43264d3363295eb8d6901e02f467897
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)
 
 getCollisionBoxes (Entity $entity, AxisAlignedBB $bb, bool $entities=true)
 
 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 147 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 474 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 1406 of file World.php.

◆ actuallyDoTick()

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

Definition at line 929 of file World.php.

◆ addEntity()

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

InvalidArgumentException

Definition at line 2657 of file World.php.

◆ addOnUnloadCallback()

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

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

Definition at line 662 of file World.php.

◆ addParticle()

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

Definition at line 725 of file World.php.

◆ addRandomTickedBlock()

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

Definition at line 1172 of file World.php.

◆ addSound()

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

Definition at line 696 of file World.php.

◆ addTile()

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

Definition at line 2761 of file World.php.

◆ blockHash()

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

@phpstan-return BlockPosHash

Definition at line 395 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 795 of file World.php.

◆ cancelUnloadChunkRequest()

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

Definition at line 2951 of file World.php.

◆ checkSleep()

pocketmine\world\World::checkSleep ( )

Definition at line 1055 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 415 of file World.php.

◆ chunkHash()

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

@phpstan-return ChunkPosHash

Definition at line 376 of file World.php.

Referenced by pocketmine\player\ChunkSelector\selectChunks().

+ Here is the caller graph for this function:

◆ clearCache()

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

Definition at line 1138 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 1657 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 1619 of file World.php.

◆ createBlockUpdatePackets()

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

Definition at line 1092 of file World.php.

◆ doChunkGarbageCollection()

pocketmine\world\World::doChunkGarbageCollection ( )

Definition at line 3476 of file World.php.

◆ doTick()

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

Definition at line 914 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 2016 of file World.php.

◆ dropItem()

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

Definition at line 1996 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 2469 of file World.php.

◆ getAutoSave()

pocketmine\world\World::getAutoSave ( )

Definition at line 751 of file World.php.

◆ getBiome()

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

Definition at line 2420 of file World.php.

◆ getBiomeId()

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

Definition at line 2413 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 1870 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 1883 of file World.php.

◆ getBlockCollisionBoxes()

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

Definition at line 1566 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 1762 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 425 of file World.php.

◆ getChunk()

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

Implements pocketmine\world\ChunkManager.

Definition at line 2444 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 2452 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 891 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 778 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 768 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 1187 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 2302 of file World.php.

◆ getCollisionBlocks()

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

Definition at line 1501 of file World.php.

◆ getCollisionBoxes()

pocketmine\world\World::getCollisionBoxes ( Entity  $entity,
AxisAlignedBB  $bb,
bool  $entities = true 
)
Deprecated:
Use World::getBlockCollisionBoxes() instead (alongside World::getCollidingEntities() if entity collision boxes are also required).
Returns
AxisAlignedBB[] @phpstan-return list<AxisAlignedBB>

Definition at line 1603 of file World.php.

References pocketmine\math\AxisAlignedBB\expandedCopy().

+ Here is the call graph for this function:

◆ getDifficulty()

pocketmine\world\World::getDifficulty ( )

Definition at line 3192 of file World.php.

◆ getDifficultyFromString()

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

Definition at line 445 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 3132 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 2288 of file World.php.

◆ getEntity()

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

Definition at line 2278 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 3149 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 1676 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 1687 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 1832 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 1700 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 1817 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 1727 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 1825 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 2606 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 610 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 2440 of file World.php.

◆ getLogger()

pocketmine\world\World::getLogger ( )

Definition at line 599 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 3188 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 3184 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 2320 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 2352 of file World.php.

◆ getOrLoadChunkAtPosition()

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

Returns the chunk containing the given Vector3 position.

Definition at line 2459 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 2392 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 1737 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 1708 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 1719 of file World.php.

◆ getProvider()

pocketmine\world\World::getProvider ( )
final

Definition at line 603 of file World.php.

◆ getRandomTickedBlocks()

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

Definition at line 1168 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 1752 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 3075 of file World.php.

◆ getSeed()

pocketmine\world\World::getSeed ( )

Gets the world seed

Definition at line 3180 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 595 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 1668 of file World.php.

◆ getSpawnLocation()

pocketmine\world\World::getSpawnLocation ( )

Returns a Position pointing to the spawn

Definition at line 2636 of file World.php.

◆ getSunAngleDegrees()

pocketmine\world\World::getSunAngleDegrees ( )

Returns the current sun angle in degrees.

Definition at line 1649 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 1635 of file World.php.

◆ getSunAngleRadians()

pocketmine\world\World::getSunAngleRadians ( )

Returns the current sun angle in radians.

Definition at line 1642 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 1206 of file World.php.

◆ getTickRateTime()

pocketmine\world\World::getTickRateTime ( )

Definition at line 576 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 2402 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 2409 of file World.php.

◆ getTime()

pocketmine\world\World::getTime ( )

Gets the current time

Definition at line 3117 of file World.php.

◆ getTimeOfDay()

pocketmine\world\World::getTimeOfDay ( )

Returns the current time of day

Definition at line 3124 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 788 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 441 of file World.php.

◆ isChunkGenerated()

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

Definition at line 2624 of file World.php.

◆ isChunkInUse()

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

Definition at line 2807 of file World.php.

◆ isChunkLoaded()

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

Definition at line 2620 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 2529 of file World.php.

◆ isChunkPopulated()

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

Definition at line 2628 of file World.php.

◆ isDoingTick()

pocketmine\world\World::isDoingTick ( )

Definition at line 907 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 2616 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 1852 of file World.php.

◆ isLoaded()

pocketmine\world\World::isLoaded ( )

Definition at line 614 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 3034 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 2817 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 2497 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 1493 of file World.php.

◆ onEntityMoved()

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

Definition at line 2716 of file World.php.

◆ onUnload()

pocketmine\world\World::onUnload ( )

Definition at line 621 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 3318 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 845 of file World.php.

◆ registerChunkLoader()

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

Definition at line 807 of file World.php.

◆ registerGeneratorToWorker()

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

Definition at line 580 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 1214 of file World.php.

◆ removeEntity()

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

Removes the entity from the world index

Exceptions

InvalidArgumentException

Definition at line 2686 of file World.php.

◆ removeOnUnloadCallback()

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

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

Definition at line 667 of file World.php.

◆ removeRandomTickedBlock()

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

Definition at line 1179 of file World.php.

◆ removeTile()

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

Definition at line 2790 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 3295 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 3049 of file World.php.

◆ save()

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

Definition at line 1410 of file World.php.

◆ saveChunks()

pocketmine\world\World::saveChunks ( )

Definition at line 1430 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 1452 of file World.php.

◆ sendTime()

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

Definition at line 898 of file World.php.

◆ setAutoSave()

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

Definition at line 755 of file World.php.

◆ setBiomeId()

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

Definition at line 2424 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 1934 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 1946 of file World.php.

◆ setChunk()

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

Implements pocketmine\world\ChunkManager.

Definition at line 2533 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 1195 of file World.php.

◆ setDifficulty()

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

Definition at line 3196 of file World.php.

◆ setDisplayName()

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

Sets the World display name.

Definition at line 3139 of file World.php.

◆ setSleepTicks()

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

Definition at line 1081 of file World.php.

◆ setSpawnLocation()

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

Sets the world spawn location

Definition at line 2643 of file World.php.

◆ setTime()

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

Sets the current time on the world

Definition at line 3156 of file World.php.

◆ startTime()

pocketmine\world\World::startTime ( )

Start the time again, if it was stopped

Definition at line 3172 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 3164 of file World.php.

◆ unloadChunk()

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

Definition at line 2955 of file World.php.

◆ unloadChunkRequest()

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

Definition at line 2941 of file World.php.

◆ unloadChunks()

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

Definition at line 3494 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 2514 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 862 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 878 of file World.php.

◆ unregisterChunkLoader()

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

Definition at line 825 of file World.php.

◆ unregisterGenerator()

pocketmine\world\World::unregisterGenerator ( )

Definition at line 586 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 1224 of file World.php.

◆ updateAllLight()

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

Definition at line 1772 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 2040 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 2146 of file World.php.

Member Data Documentation

◆ $stopTime

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

Definition at line 271 of file World.php.

◆ $tickRateTime

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

Definition at line 354 of file World.php.

◆ $timings

WorldTimings pocketmine\world\World::$timings

Definition at line 352 of file World.php.

◆ $updateEntities

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

Definition at line 197 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 168 of file World.php.

◆ DIFFICULTY_EASY

const pocketmine\world\World::DIFFICULTY_EASY = 1

Definition at line 164 of file World.php.

◆ DIFFICULTY_HARD

const pocketmine\world\World::DIFFICULTY_HARD = 3

Definition at line 166 of file World.php.

◆ DIFFICULTY_NORMAL

const pocketmine\world\World::DIFFICULTY_NORMAL = 2

Definition at line 165 of file World.php.

◆ DIFFICULTY_PEACEFUL

const pocketmine\world\World::DIFFICULTY_PEACEFUL = 0

Definition at line 163 of file World.php.

◆ TIME_DAY

const pocketmine\world\World::TIME_DAY = 1000

Definition at line 154 of file World.php.

◆ TIME_FULL

const pocketmine\world\World::TIME_FULL = 24000

Definition at line 161 of file World.php.

◆ TIME_MIDNIGHT

const pocketmine\world\World::TIME_MIDNIGHT = 18000

Definition at line 158 of file World.php.

◆ TIME_NIGHT

const pocketmine\world\World::TIME_NIGHT = 13000

Definition at line 157 of file World.php.

◆ TIME_NOON

const pocketmine\world\World::TIME_NOON = 6000

Definition at line 155 of file World.php.

◆ TIME_SUNRISE

const pocketmine\world\World::TIME_SUNRISE = 23000

Definition at line 159 of file World.php.

◆ TIME_SUNSET

const pocketmine\world\World::TIME_SUNSET = 12000

Definition at line 156 of file World.php.

◆ Y_MAX

const pocketmine\world\World::Y_MAX = 320

Definition at line 151 of file World.php.

◆ Y_MIN

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

Definition at line 152 of file World.php.


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