mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-23 19:34:15 +00:00
Merge branch 'next-minor' into next-major
This commit is contained in:
commit
9f6c6b2b71
@ -55,7 +55,7 @@
|
|||||||
"symfony/filesystem": "^5.4"
|
"symfony/filesystem": "^5.4"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpstan/phpstan": "1.8.8",
|
"phpstan/phpstan": "1.8.9",
|
||||||
"phpstan/phpstan-phpunit": "^1.1.0",
|
"phpstan/phpstan-phpunit": "^1.1.0",
|
||||||
"phpstan/phpstan-strict-rules": "^1.2.0",
|
"phpstan/phpstan-strict-rules": "^1.2.0",
|
||||||
"phpunit/phpunit": "^9.2"
|
"phpunit/phpunit": "^9.2"
|
||||||
|
14
composer.lock
generated
14
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "94c6278cb07e5bfe8b20c93c17b59135",
|
"content-hash": "1053875fbf22e06a28c612aae6aa5c6b",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adhocore/json-comment",
|
"name": "adhocore/json-comment",
|
||||||
@ -1767,16 +1767,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan",
|
"name": "phpstan/phpstan",
|
||||||
"version": "1.8.8",
|
"version": "1.8.9",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpstan.git",
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
"reference": "08310ce271984587e2a4cda94e1ac66510a6ea07"
|
"reference": "3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/08310ce271984587e2a4cda94e1ac66510a6ea07",
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2",
|
||||||
"reference": "08310ce271984587e2a4cda94e1ac66510a6ea07",
|
"reference": "3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -1806,7 +1806,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/phpstan/phpstan/issues",
|
"issues": "https://github.com/phpstan/phpstan/issues",
|
||||||
"source": "https://github.com/phpstan/phpstan/tree/1.8.8"
|
"source": "https://github.com/phpstan/phpstan/tree/1.8.9"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -1822,7 +1822,7 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2022-10-06T12:51:57+00:00"
|
"time": "2022-10-13T13:40:18+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan-phpunit",
|
"name": "phpstan/phpstan-phpunit",
|
||||||
|
@ -610,8 +610,8 @@ class Server{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated This method's results are unpredictable. The string "Steve" will return the player named "SteveJobs",
|
* @deprecated This method's results are unpredictable. The string "Steve" will return the player named "SteveJobs",
|
||||||
* until another player named "Steve" joins the server, at which point it will return that player instead. Use
|
* until another player named "SteveJ" joins the server, at which point it will return that player instead. Prefer
|
||||||
* {@link Server::getPlayersByPrefix()} instead.
|
* filtering the results of {@link Server::getOnlinePlayers()} yourself.
|
||||||
*
|
*
|
||||||
* Returns an online player whose name begins with or equals the given string (case insensitive).
|
* Returns an online player whose name begins with or equals the given string (case insensitive).
|
||||||
* The closest match will be returned, or null if there are no online matches.
|
* The closest match will be returned, or null if there are no online matches.
|
||||||
|
@ -130,7 +130,6 @@ class FallingBlock extends Entity{
|
|||||||
|
|
||||||
$block = $world->getBlock($pos);
|
$block = $world->getBlock($pos);
|
||||||
if(!$block->canBeReplaced() || !$world->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()) || ($this->onGround && abs($this->location->y - $this->location->getFloorY()) > 0.001)){
|
if(!$block->canBeReplaced() || !$world->isInWorld($pos->getFloorX(), $pos->getFloorY(), $pos->getFloorZ()) || ($this->onGround && abs($this->location->y - $this->location->getFloorY()) > 0.001)){
|
||||||
//FIXME: anvils are supposed to destroy torches
|
|
||||||
$world->dropItem($this->location, $this->block->asItem());
|
$world->dropItem($this->location, $this->block->asItem());
|
||||||
}else{
|
}else{
|
||||||
$ev = new EntityBlockChangeEvent($this, $block, $blockTarget ?? $this->block);
|
$ev = new EntityBlockChangeEvent($this, $block, $blockTarget ?? $this->block);
|
||||||
|
@ -131,6 +131,11 @@ use const PHP_INT_MIN;
|
|||||||
|
|
||||||
#include <rules/World.h>
|
#include <rules/World.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-type ChunkPosHash int
|
||||||
|
* @phpstan-type BlockPosHash int
|
||||||
|
* @phpstan-type ChunkBlockPosHash int
|
||||||
|
*/
|
||||||
class World implements ChunkManager{
|
class World implements ChunkManager{
|
||||||
|
|
||||||
private static int $worldIdCounter = 1;
|
private static int $worldIdCounter = 1;
|
||||||
@ -154,28 +159,40 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
public const DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK = 3;
|
public const DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK = 3;
|
||||||
|
|
||||||
/** @var Player[] */
|
/**
|
||||||
|
* @var Player[] entity runtime ID => Player
|
||||||
|
* @phpstan-var array<int, Player>
|
||||||
|
*/
|
||||||
private array $players = [];
|
private array $players = [];
|
||||||
|
|
||||||
/** @var Entity[] */
|
/**
|
||||||
|
* @var Entity[] entity runtime ID => Entity
|
||||||
|
* @phpstan-var array<int, Entity>
|
||||||
|
*/
|
||||||
private array $entities = [];
|
private array $entities = [];
|
||||||
/**
|
/**
|
||||||
* @var Vector3[]
|
* @var Vector3[] entity runtime ID => Vector3
|
||||||
* @phpstan-var array<int, Vector3>
|
* @phpstan-var array<int, Vector3>
|
||||||
*/
|
*/
|
||||||
private array $entityLastKnownPositions = [];
|
private array $entityLastKnownPositions = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Entity[][]
|
* @var Entity[][] chunkHash => [entity runtime ID => Entity]
|
||||||
* @phpstan-var array<int, array<int, Entity>>
|
* @phpstan-var array<ChunkPosHash, array<int, Entity>>
|
||||||
*/
|
*/
|
||||||
private array $entitiesByChunk = [];
|
private array $entitiesByChunk = [];
|
||||||
|
|
||||||
/** @var Entity[] */
|
/**
|
||||||
|
* @var Entity[] entity runtime ID => Entity
|
||||||
|
* @phpstan-var array<int, Entity>
|
||||||
|
*/
|
||||||
public array $updateEntities = [];
|
public array $updateEntities = [];
|
||||||
|
|
||||||
private bool $inDynamicStateRecalculation = false;
|
private bool $inDynamicStateRecalculation = false;
|
||||||
/** @var Block[][] */
|
/**
|
||||||
|
* @var Block[][] chunkHash => [relativeBlockHash => Block]
|
||||||
|
* @phpstan-var array<ChunkPosHash, array<ChunkBlockPosHash, Block>>
|
||||||
|
*/
|
||||||
private array $blockCache = [];
|
private array $blockCache = [];
|
||||||
|
|
||||||
private int $sendTimeTicker = 0;
|
private int $sendTimeTicker = 0;
|
||||||
@ -187,22 +204,43 @@ class World implements ChunkManager{
|
|||||||
private int $minY;
|
private int $minY;
|
||||||
private int $maxY;
|
private int $maxY;
|
||||||
|
|
||||||
/** @var TickingChunkLoader[] */
|
/**
|
||||||
|
* @var TickingChunkLoader[] spl_object_id => TickingChunkLoader
|
||||||
|
* @phpstan-var array<int, TickingChunkLoader>
|
||||||
|
*/
|
||||||
private array $tickingLoaders = [];
|
private array $tickingLoaders = [];
|
||||||
/** @var int[] */
|
/**
|
||||||
|
* @var int[] spl_object_id => number of chunks
|
||||||
|
* @phpstan-var array<int, int>
|
||||||
|
*/
|
||||||
private array $tickingLoaderCounter = [];
|
private array $tickingLoaderCounter = [];
|
||||||
/** @var ChunkLoader[][] */
|
/**
|
||||||
|
* @var ChunkLoader[][] chunkHash => [spl_object_id => ChunkLoader]
|
||||||
|
* @phpstan-var array<ChunkPosHash, array<int, ChunkLoader>>
|
||||||
|
*/
|
||||||
private array $chunkLoaders = [];
|
private array $chunkLoaders = [];
|
||||||
|
|
||||||
/** @var ChunkListener[][] */
|
/**
|
||||||
|
* @var ChunkListener[][] chunkHash => [spl_object_id => ChunkListener]
|
||||||
|
* @phpstan-var array<ChunkPosHash, array<int, ChunkListener>>
|
||||||
|
*/
|
||||||
private array $chunkListeners = [];
|
private array $chunkListeners = [];
|
||||||
/** @var Player[][] */
|
/**
|
||||||
|
* @var Player[][] chunkHash => [spl_object_id => Player]
|
||||||
|
* @phpstan-var array<ChunkPosHash, array<int, Player>>
|
||||||
|
*/
|
||||||
private array $playerChunkListeners = [];
|
private array $playerChunkListeners = [];
|
||||||
|
|
||||||
/** @var ClientboundPacket[][] */
|
/**
|
||||||
|
* @var ClientboundPacket[][]
|
||||||
|
* @phpstan-var array<ChunkPosHash, list<ClientboundPacket>>
|
||||||
|
*/
|
||||||
private array $packetBuffersByChunk = [];
|
private array $packetBuffersByChunk = [];
|
||||||
|
|
||||||
/** @var float[] */
|
/**
|
||||||
|
* @var float[] chunkHash => timestamp of request
|
||||||
|
* @phpstan-var array<ChunkPosHash, float>
|
||||||
|
*/
|
||||||
private array $unloadQueue = [];
|
private array $unloadQueue = [];
|
||||||
|
|
||||||
private int $time;
|
private int $time;
|
||||||
@ -214,44 +252,65 @@ class World implements ChunkManager{
|
|||||||
private string $folderName;
|
private string $folderName;
|
||||||
private string $displayName;
|
private string $displayName;
|
||||||
|
|
||||||
/** @var Chunk[] */
|
/**
|
||||||
|
* @var Chunk[]
|
||||||
|
* @phpstan-var array<ChunkPosHash, Chunk>
|
||||||
|
*/
|
||||||
private array $chunks = [];
|
private array $chunks = [];
|
||||||
|
|
||||||
/** @var Vector3[][] */
|
/**
|
||||||
|
* @var Vector3[][] chunkHash => [relativeBlockHash => Vector3]
|
||||||
|
* @phpstan-var array<ChunkPosHash, array<ChunkBlockPosHash, Vector3>>
|
||||||
|
*/
|
||||||
private array $changedBlocks = [];
|
private array $changedBlocks = [];
|
||||||
|
|
||||||
/** @phpstan-var ReversePriorityQueue<int, Vector3> */
|
/** @phpstan-var ReversePriorityQueue<int, Vector3> */
|
||||||
private ReversePriorityQueue $scheduledBlockUpdateQueue;
|
private ReversePriorityQueue $scheduledBlockUpdateQueue;
|
||||||
/** @var int[] */
|
/**
|
||||||
|
* @var int[] blockHash => tick delay
|
||||||
|
* @phpstan-var array<BlockPosHash, int>
|
||||||
|
*/
|
||||||
private array $scheduledBlockUpdateQueueIndex = [];
|
private array $scheduledBlockUpdateQueueIndex = [];
|
||||||
|
|
||||||
/** @phpstan-var \SplQueue<int> */
|
/** @phpstan-var \SplQueue<int> */
|
||||||
private \SplQueue $neighbourBlockUpdateQueue;
|
private \SplQueue $neighbourBlockUpdateQueue;
|
||||||
/** @var bool[] blockhash => dummy */
|
/**
|
||||||
|
* @var true[] blockhash => dummy
|
||||||
|
* @phpstan-var array<BlockPosHash, true>
|
||||||
|
*/
|
||||||
private array $neighbourBlockUpdateQueueIndex = [];
|
private array $neighbourBlockUpdateQueueIndex = [];
|
||||||
|
|
||||||
/** @var bool[] */
|
/**
|
||||||
|
* @var bool[] chunkHash => isValid
|
||||||
|
* @phpstan-var array<ChunkPosHash, bool>
|
||||||
|
*/
|
||||||
private array $activeChunkPopulationTasks = [];
|
private array $activeChunkPopulationTasks = [];
|
||||||
/** @var ChunkLockId[] */
|
/**
|
||||||
|
* @var ChunkLockId[]
|
||||||
|
* @phpstan-var array<ChunkPosHash, ChunkLockId>
|
||||||
|
*/
|
||||||
private array $chunkLock = [];
|
private array $chunkLock = [];
|
||||||
private int $maxConcurrentChunkPopulationTasks = 2;
|
private int $maxConcurrentChunkPopulationTasks = 2;
|
||||||
/**
|
/**
|
||||||
* @var PromiseResolver[] chunkHash => promise
|
* @var PromiseResolver[] chunkHash => promise
|
||||||
* @phpstan-var array<int, PromiseResolver<Chunk>>
|
* @phpstan-var array<ChunkPosHash, PromiseResolver<Chunk>>
|
||||||
*/
|
*/
|
||||||
private array $chunkPopulationRequestMap = [];
|
private array $chunkPopulationRequestMap = [];
|
||||||
/**
|
/**
|
||||||
* @var \SplQueue (queue of chunkHashes)
|
* @var \SplQueue (queue of chunkHashes)
|
||||||
* @phpstan-var \SplQueue<int>
|
* @phpstan-var \SplQueue<ChunkPosHash>
|
||||||
*/
|
*/
|
||||||
private \SplQueue $chunkPopulationRequestQueue;
|
private \SplQueue $chunkPopulationRequestQueue;
|
||||||
/**
|
/**
|
||||||
* @var true[] chunkHash => dummy
|
* @var true[] chunkHash => dummy
|
||||||
* @phpstan-var array<int, true>
|
* @phpstan-var array<ChunkPosHash, true>
|
||||||
*/
|
*/
|
||||||
private array $chunkPopulationRequestQueueIndex = [];
|
private array $chunkPopulationRequestQueueIndex = [];
|
||||||
|
|
||||||
/** @var bool[] */
|
/**
|
||||||
|
* @var true[]
|
||||||
|
* @phpstan-var array<int, true>
|
||||||
|
*/
|
||||||
private array $generatorRegisteredWorkers = [];
|
private array $generatorRegisteredWorkers = [];
|
||||||
|
|
||||||
private bool $autoSave = true;
|
private bool $autoSave = true;
|
||||||
@ -261,7 +320,10 @@ class World implements ChunkManager{
|
|||||||
private int $chunkTickRadius;
|
private int $chunkTickRadius;
|
||||||
private int $chunksPerTick;
|
private int $chunksPerTick;
|
||||||
private int $tickedBlocksPerSubchunkPerTick = self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK;
|
private int $tickedBlocksPerSubchunkPerTick = self::DEFAULT_TICKED_BLOCKS_PER_SUBCHUNK_PER_TICK;
|
||||||
/** @var bool[] */
|
/**
|
||||||
|
* @var true[]
|
||||||
|
* @phpstan-var array<int, true>
|
||||||
|
*/
|
||||||
private array $randomTickBlocks = [];
|
private array $randomTickBlocks = [];
|
||||||
|
|
||||||
public WorldTimings $timings;
|
public WorldTimings $timings;
|
||||||
@ -285,6 +347,9 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
private \Logger $logger;
|
private \Logger $logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-return ChunkPosHash
|
||||||
|
*/
|
||||||
public static function chunkHash(int $x, int $z) : int{
|
public static function chunkHash(int $x, int $z) : int{
|
||||||
return morton2d_encode($x, $z);
|
return morton2d_encode($x, $z);
|
||||||
}
|
}
|
||||||
@ -301,6 +366,9 @@ class World implements ChunkManager{
|
|||||||
private const BLOCKHASH_X_SHIFT = self::BLOCKHASH_Y_BITS;
|
private const BLOCKHASH_X_SHIFT = self::BLOCKHASH_Y_BITS;
|
||||||
private const BLOCKHASH_Z_SHIFT = self::BLOCKHASH_X_SHIFT + self::BLOCKHASH_XZ_EXTRA_BITS;
|
private const BLOCKHASH_Z_SHIFT = self::BLOCKHASH_X_SHIFT + self::BLOCKHASH_XZ_EXTRA_BITS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-return BlockPosHash
|
||||||
|
*/
|
||||||
public static function blockHash(int $x, int $y, int $z) : int{
|
public static function blockHash(int $x, int $y, int $z) : int{
|
||||||
$shiftedY = $y + self::BLOCKHASH_Y_OFFSET;
|
$shiftedY = $y + self::BLOCKHASH_Y_OFFSET;
|
||||||
if(($shiftedY & (~0 << self::BLOCKHASH_Y_BITS)) !== 0){
|
if(($shiftedY & (~0 << self::BLOCKHASH_Y_BITS)) !== 0){
|
||||||
@ -325,6 +393,9 @@ class World implements ChunkManager{
|
|||||||
return morton3d_encode($x, $y, $z);
|
return morton3d_encode($x, $y, $z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param BlockPosHash $hash
|
||||||
|
*/
|
||||||
public static function getBlockXYZ(int $hash, ?int &$x, ?int &$y, ?int &$z) : void{
|
public static function getBlockXYZ(int $hash, ?int &$x, ?int &$y, ?int &$z) : void{
|
||||||
[$baseX, $baseY, $baseZ] = morton3d_decode($hash);
|
[$baseX, $baseY, $baseZ] = morton3d_decode($hash);
|
||||||
|
|
||||||
@ -336,6 +407,9 @@ class World implements ChunkManager{
|
|||||||
$z = (($baseZ & self::BLOCKHASH_XZ_MASK) | $extraZ) << self::BLOCKHASH_XZ_SIGN_SHIFT >> self::BLOCKHASH_XZ_SIGN_SHIFT;
|
$z = (($baseZ & self::BLOCKHASH_XZ_MASK) | $extraZ) << self::BLOCKHASH_XZ_SIGN_SHIFT >> self::BLOCKHASH_XZ_SIGN_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phpstan-param ChunkPosHash $hash
|
||||||
|
*/
|
||||||
public static function getXZ(int $hash, ?int &$x, ?int &$z) : void{
|
public static function getXZ(int $hash, ?int &$x, ?int &$z) : void{
|
||||||
[$x, $z] = morton2d_decode($hash);
|
[$x, $z] = morton2d_decode($hash);
|
||||||
}
|
}
|
||||||
@ -560,6 +634,28 @@ class World implements ChunkManager{
|
|||||||
unset($this->unloadCallbacks[spl_object_id($callback)]);
|
unset($this->unloadCallbacks[spl_object_id($callback)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of players who are in the given filter and also using the chunk containing the target position.
|
||||||
|
* Used for broadcasting sounds and particles with specific targets.
|
||||||
|
*
|
||||||
|
* @param Player[] $allowed
|
||||||
|
* @phpstan-param list<Player> $allowed
|
||||||
|
*
|
||||||
|
* @return array<int, Player>
|
||||||
|
*/
|
||||||
|
private function filterViewersForPosition(Vector3 $pos, array $allowed) : array{
|
||||||
|
$candidates = $this->getViewersForPosition($pos);
|
||||||
|
$filtered = [];
|
||||||
|
foreach($allowed as $player){
|
||||||
|
$k = spl_object_id($player);
|
||||||
|
if(isset($candidates[$k])){
|
||||||
|
$filtered[$k] = $candidates[$k];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filtered;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Player[]|null $players
|
* @param Player[]|null $players
|
||||||
*/
|
*/
|
||||||
@ -571,7 +667,7 @@ class World implements ChunkManager{
|
|||||||
$this->broadcastPacketToViewers($pos, $e);
|
$this->broadcastPacketToViewers($pos, $e);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->server->broadcastPackets($players, $pk);
|
$this->server->broadcastPackets($this->filterViewersForPosition($pos, $players), $pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -587,7 +683,7 @@ class World implements ChunkManager{
|
|||||||
$this->broadcastPacketToViewers($pos, $e);
|
$this->broadcastPacketToViewers($pos, $e);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$this->server->broadcastPackets($players, $pk);
|
$this->server->broadcastPackets($this->filterViewersForPosition($pos, $players), $pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -606,7 +702,8 @@ class World implements ChunkManager{
|
|||||||
*
|
*
|
||||||
* Returns a list of players who have the target chunk within their view distance.
|
* Returns a list of players who have the target chunk within their view distance.
|
||||||
*
|
*
|
||||||
* @return Player[]
|
* @return Player[] spl_object_id => Player
|
||||||
|
* @phpstan-return array<int, Player>
|
||||||
*/
|
*/
|
||||||
public function getChunkPlayers(int $chunkX, int $chunkZ) : array{
|
public function getChunkPlayers(int $chunkX, int $chunkZ) : array{
|
||||||
return $this->playerChunkListeners[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
return $this->playerChunkListeners[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
||||||
@ -616,6 +713,7 @@ class World implements ChunkManager{
|
|||||||
* Gets the chunk loaders being used in a specific chunk
|
* Gets the chunk loaders being used in a specific chunk
|
||||||
*
|
*
|
||||||
* @return ChunkLoader[]
|
* @return ChunkLoader[]
|
||||||
|
* @phpstan-return array<int, ChunkLoader>
|
||||||
*/
|
*/
|
||||||
public function getChunkLoaders(int $chunkX, int $chunkZ) : array{
|
public function getChunkLoaders(int $chunkX, int $chunkZ) : array{
|
||||||
return $this->chunkLoaders[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
return $this->chunkLoaders[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
||||||
@ -624,7 +722,8 @@ class World implements ChunkManager{
|
|||||||
/**
|
/**
|
||||||
* Returns an array of players who have the target position within their view distance.
|
* Returns an array of players who have the target position within their view distance.
|
||||||
*
|
*
|
||||||
* @return Player[]
|
* @return Player[] spl_object_id => Player
|
||||||
|
* @phpstan-return array<int, Player>
|
||||||
*/
|
*/
|
||||||
public function getViewersForPosition(Vector3 $pos) : array{
|
public function getViewersForPosition(Vector3 $pos) : array{
|
||||||
return $this->getChunkPlayers($pos->getFloorX() >> Chunk::COORD_BIT_SIZE, $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE);
|
return $this->getChunkPlayers($pos->getFloorX() >> Chunk::COORD_BIT_SIZE, $pos->getFloorZ() >> Chunk::COORD_BIT_SIZE);
|
||||||
@ -739,6 +838,7 @@ class World implements ChunkManager{
|
|||||||
* Returns all the listeners attached to this chunk.
|
* Returns all the listeners attached to this chunk.
|
||||||
*
|
*
|
||||||
* @return ChunkListener[]
|
* @return ChunkListener[]
|
||||||
|
* @phpstan-return array<int, ChunkListener>
|
||||||
*/
|
*/
|
||||||
public function getChunkListeners(int $chunkX, int $chunkZ) : array{
|
public function getChunkListeners(int $chunkX, int $chunkZ) : array{
|
||||||
return $this->chunkListeners[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
return $this->chunkListeners[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
||||||
@ -936,8 +1036,10 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3[] $blocks
|
* @param Vector3[] $blocks
|
||||||
|
* @phpstan-param list<Vector3> $blocks
|
||||||
*
|
*
|
||||||
* @return ClientboundPacket[]
|
* @return ClientboundPacket[]
|
||||||
|
* @phpstan-return list<ClientboundPacket>
|
||||||
*/
|
*/
|
||||||
public function createBlockUpdatePackets(array $blocks) : array{
|
public function createBlockUpdatePackets(array $blocks) : array{
|
||||||
$packets = [];
|
$packets = [];
|
||||||
@ -998,7 +1100,8 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool[] fullID => bool
|
* @return true[] fullID => dummy
|
||||||
|
* @phpstan-return array<int, true>
|
||||||
*/
|
*/
|
||||||
public function getRandomTickedBlocks() : array{
|
public function getRandomTickedBlocks() : array{
|
||||||
return $this->randomTickBlocks;
|
return $this->randomTickBlocks;
|
||||||
@ -1220,6 +1323,7 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Block[]
|
* @return Block[]
|
||||||
|
* @phpstan-return list<Block>
|
||||||
*/
|
*/
|
||||||
public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{
|
public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{
|
||||||
$minX = (int) floor($bb->minX - 1);
|
$minX = (int) floor($bb->minX - 1);
|
||||||
@ -1260,6 +1364,7 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AxisAlignedBB[]
|
* @return AxisAlignedBB[]
|
||||||
|
* @phpstan-return list<AxisAlignedBB>
|
||||||
*/
|
*/
|
||||||
public function getCollisionBoxes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
public function getCollisionBoxes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
||||||
$minX = (int) floor($bb->minX - 1);
|
$minX = (int) floor($bb->minX - 1);
|
||||||
@ -1663,6 +1768,7 @@ class World implements ChunkManager{
|
|||||||
* Drops XP orbs into the world for the specified amount, splitting the amount into several orbs if necessary.
|
* Drops XP orbs into the world for the specified amount, splitting the amount into several orbs if necessary.
|
||||||
*
|
*
|
||||||
* @return ExperienceOrb[]
|
* @return ExperienceOrb[]
|
||||||
|
* @phpstan-return list<ExperienceOrb>
|
||||||
*/
|
*/
|
||||||
public function dropExperience(Vector3 $pos, int $amount) : array{
|
public function dropExperience(Vector3 $pos, int $amount) : array{
|
||||||
/** @var ExperienceOrb[] $orbs */
|
/** @var ExperienceOrb[] $orbs */
|
||||||
@ -1920,18 +2026,24 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list of all the entities in this world
|
* Returns a list of all the entities in this world, indexed by their entity runtime IDs
|
||||||
*
|
*
|
||||||
* @return Entity[]
|
* @return Entity[]
|
||||||
|
* @phpstan-return array<int, Entity>
|
||||||
*/
|
*/
|
||||||
public function getEntities() : array{
|
public function getEntities() : array{
|
||||||
return $this->entities;
|
return $this->entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entities colliding the current one inside the AxisAlignedBB
|
* 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 {@link World::getNearbyEntities()}, but with additional collidability filters.
|
||||||
*
|
*
|
||||||
* @return Entity[]
|
* @return Entity[]
|
||||||
|
* @phpstan-return array<int, Entity>
|
||||||
*/
|
*/
|
||||||
public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
|
public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
|
||||||
$nearby = [];
|
$nearby = [];
|
||||||
@ -1946,9 +2058,10 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the entities near the current one inside the AxisAlignedBB
|
* Returns all entities whose bounding boxes intersect the given bounding box, excluding the given entity.
|
||||||
*
|
*
|
||||||
* @return Entity[]
|
* @return Entity[]
|
||||||
|
* @phpstan-return array<int, Entity>
|
||||||
*/
|
*/
|
||||||
public function getNearbyEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
|
public function getNearbyEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
|
||||||
$nearby = [];
|
$nearby = [];
|
||||||
@ -2025,7 +2138,8 @@ class World implements ChunkManager{
|
|||||||
/**
|
/**
|
||||||
* Returns a list of the players in this world
|
* Returns a list of the players in this world
|
||||||
*
|
*
|
||||||
* @return Player[]
|
* @return Player[] entity runtime ID => Player
|
||||||
|
* @phpstan-return array<int, Player>
|
||||||
*/
|
*/
|
||||||
public function getPlayers() : array{
|
public function getPlayers() : array{
|
||||||
return $this->players;
|
return $this->players;
|
||||||
@ -2072,7 +2186,8 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Chunk[]
|
* @return Chunk[] chunkHash => Chunk
|
||||||
|
* @phpstan-return array<ChunkPosHash, Chunk>
|
||||||
*/
|
*/
|
||||||
public function getLoadedChunks() : array{
|
public function getLoadedChunks() : array{
|
||||||
return $this->chunks;
|
return $this->chunks;
|
||||||
@ -2083,7 +2198,8 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Entity[]
|
* @return Entity[] entity runtime ID => Entity
|
||||||
|
* @phpstan-return array<int, Entity>
|
||||||
*/
|
*/
|
||||||
public function getChunkEntities(int $chunkX, int $chunkZ) : array{
|
public function getChunkEntities(int $chunkX, int $chunkZ) : array{
|
||||||
return $this->entitiesByChunk[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
return $this->entitiesByChunk[World::chunkHash($chunkX, $chunkZ)] ?? [];
|
||||||
@ -2099,7 +2215,8 @@ class World implements ChunkManager{
|
|||||||
/**
|
/**
|
||||||
* Returns the chunks adjacent to the specified chunk.
|
* Returns the chunks adjacent to the specified chunk.
|
||||||
*
|
*
|
||||||
* @return Chunk[]|null[]
|
* @return Chunk[]|null[] chunkHash => Chunk|null
|
||||||
|
* @phpstan-return array<ChunkPosHash, Chunk|null>
|
||||||
*/
|
*/
|
||||||
public function getAdjacentChunks(int $x, int $z) : array{
|
public function getAdjacentChunks(int $x, int $z) : array{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user