mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
phpdoc armageddon for master, pass 1
This commit is contained in:
@@ -271,12 +271,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Computes a small index relative to chunk base from the given coordinates.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function chunkBlockHash(int $x, int $y, int $z) : int{
|
||||
return ($y << 8) | (($z & 0xf) << 4) | ($x & 0xf);
|
||||
@@ -288,21 +282,11 @@ class World implements ChunkManager{
|
||||
$z = $hash << 37 >> 37;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $hash
|
||||
* @param int|null $x
|
||||
* @param int|null $z
|
||||
*/
|
||||
public static function getXZ(int $hash, ?int &$x, ?int &$z) : void{
|
||||
$x = $hash >> 32;
|
||||
$z = ($hash & 0xFFFFFFFF) << 32 >> 32;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $str
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getDifficultyFromString(string $str) : int{
|
||||
switch(strtolower(trim($str))){
|
||||
case "0":
|
||||
@@ -331,10 +315,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Init the default world data
|
||||
*
|
||||
* @param Server $server
|
||||
* @param string $name
|
||||
* @param WritableWorldProvider $provider
|
||||
*/
|
||||
public function __construct(Server $server, string $name, WritableWorldProvider $provider){
|
||||
$this->worldId = static::$worldIdCounter++;
|
||||
@@ -479,8 +459,6 @@ class World implements ChunkManager{
|
||||
* Broadcasts a LevelEvent to players in the area. This could be sound, particles, weather changes, etc.
|
||||
*
|
||||
* @param Vector3|null $pos If null, broadcasts to every player in the World
|
||||
* @param int $evid
|
||||
* @param int $data
|
||||
*/
|
||||
public function broadcastLevelEvent(?Vector3 $pos, int $evid, int $data = 0) : void{
|
||||
$pk = LevelEventPacket::create($evid, $data, $pos);
|
||||
@@ -505,9 +483,6 @@ class World implements ChunkManager{
|
||||
*
|
||||
* Returns a list of players who have the target chunk within their view distance.
|
||||
*
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
*
|
||||
* @return Player[]
|
||||
*/
|
||||
public function getChunkPlayers(int $chunkX, int $chunkZ) : array{
|
||||
@@ -517,9 +492,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Gets the chunk loaders being used in a specific chunk
|
||||
*
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
*
|
||||
* @return ChunkLoader[]
|
||||
*/
|
||||
public function getChunkLoaders(int $chunkX, int $chunkZ) : array{
|
||||
@@ -528,7 +500,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns an array of players who have the target position within their view distance.
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return Player[]
|
||||
*/
|
||||
@@ -539,10 +510,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Queues a packet to be sent to all players using the chunk at the specified X/Z coordinates at the end of the
|
||||
* current tick.
|
||||
*
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param ClientboundPacket $packet
|
||||
*/
|
||||
public function addChunkPacket(int $chunkX, int $chunkZ, ClientboundPacket $packet) : void{
|
||||
if(!isset($this->chunkPackets[$index = World::chunkHash($chunkX, $chunkZ)])){
|
||||
@@ -554,9 +521,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Broadcasts a packet to every player who has the target position within their view distance.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param ClientboundPacket $packet
|
||||
*/
|
||||
public function broadcastPacketToViewers(Vector3 $pos, ClientboundPacket $packet) : void{
|
||||
$this->addChunkPacket($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $packet);
|
||||
@@ -564,8 +528,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Broadcasts a packet to every player in the world.
|
||||
*
|
||||
* @param ClientboundPacket $packet
|
||||
*/
|
||||
public function broadcastGlobalPacket(ClientboundPacket $packet) : void{
|
||||
$this->globalPackets[] = $packet;
|
||||
@@ -621,10 +583,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Registers a listener to receive events on a chunk.
|
||||
*
|
||||
* @param ChunkListener $listener
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
*/
|
||||
public function registerChunkListener(ChunkListener $listener, int $chunkX, int $chunkZ) : void{
|
||||
$hash = World::chunkHash($chunkX, $chunkZ);
|
||||
@@ -638,10 +596,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Unregisters a chunk listener previously registered.
|
||||
*
|
||||
* @param ChunkListener $listener
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
*
|
||||
*@see World::registerChunkListener()
|
||||
*
|
||||
*/
|
||||
@@ -657,8 +611,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Unregisters a chunk listener from all chunks it is listening on in this World.
|
||||
*
|
||||
* @param ChunkListener $listener
|
||||
*/
|
||||
public function unregisterChunkListenerFromAll(ChunkListener $listener) : void{
|
||||
$id = spl_object_id($listener);
|
||||
@@ -675,9 +627,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns all the listeners attached to this chunk.
|
||||
*
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
*
|
||||
* @return ChunkListener[]
|
||||
*/
|
||||
public function getChunkListeners(int $chunkX, int $chunkZ) : array{
|
||||
@@ -705,9 +654,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param int $currentTick
|
||||
*
|
||||
*/
|
||||
public function doTick(int $currentTick) : void{
|
||||
if($this->closed){
|
||||
@@ -1009,11 +955,6 @@ class World implements ChunkManager{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $force
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save(bool $force = false) : bool{
|
||||
|
||||
if(!$this->getAutoSave() and !$force){
|
||||
@@ -1046,9 +987,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Schedules a block update to be executed after the specified number of ticks.
|
||||
* Blocks will be updated with the scheduled update type.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param int $delay
|
||||
*/
|
||||
public function scheduleDelayedBlockUpdate(Vector3 $pos, int $delay) : void{
|
||||
if(
|
||||
@@ -1072,9 +1010,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AxisAlignedBB $bb
|
||||
* @param bool $targetFirst
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{
|
||||
@@ -1116,10 +1051,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
* @param AxisAlignedBB $bb
|
||||
* @param bool $entities
|
||||
*
|
||||
* @return AxisAlignedBB[]
|
||||
*/
|
||||
public function getCollisionBoxes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{
|
||||
@@ -1170,8 +1101,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function computeSunAnglePercentage() : float{
|
||||
$timeProgress = ($this->time % 24000) / 24000;
|
||||
@@ -1188,7 +1117,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the percentage of a circle away from noon the sun is currently at.
|
||||
* @return float
|
||||
*/
|
||||
public function getSunAnglePercentage() : float{
|
||||
return $this->sunAnglePercentage;
|
||||
@@ -1196,7 +1124,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the current sun angle in radians.
|
||||
* @return float
|
||||
*/
|
||||
public function getSunAngleRadians() : float{
|
||||
return $this->sunAnglePercentage * 2 * M_PI;
|
||||
@@ -1204,7 +1131,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the current sun angle in degrees.
|
||||
* @return float
|
||||
*/
|
||||
public function getSunAngleDegrees() : float{
|
||||
return $this->sunAnglePercentage * 360.0;
|
||||
@@ -1213,8 +1139,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function computeSkyLightReduction() : int{
|
||||
$percentage = max(0, min(1, -(cos($this->getSunAngleRadians()) * 2 - 0.5)));
|
||||
@@ -1226,7 +1150,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns how many points of sky light is subtracted based on the current time.
|
||||
* @return int
|
||||
*/
|
||||
public function getSkyLightReduction() : int{
|
||||
return $this->skyLightReduction;
|
||||
@@ -1235,10 +1158,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the sky light level at the specified coordinates, offset by the current time and weather.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int 0-15
|
||||
*/
|
||||
public function getRealBlockSkyLightAt(int $x, int $y, int $z) : int{
|
||||
@@ -1264,12 +1183,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the highest block light level available in the positions adjacent to the specified block coordinates.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHighestAdjacentBlockSkyLight(int $x, int $y, int $z) : int{
|
||||
$max = 0;
|
||||
@@ -1291,12 +1204,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the highest block light level available in the positions adjacent to the specified block coordinates.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHighestAdjacentBlockLight(int $x, int $y, int $z) : int{
|
||||
$max = 0;
|
||||
@@ -1333,10 +1240,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int bitmap, (id << 4) | data
|
||||
*/
|
||||
public function getFullBlock(int $x, int $y, int $z) : int{
|
||||
@@ -1358,11 +1261,8 @@ class World implements ChunkManager{
|
||||
* Note: If you're using this for performance-sensitive code, and you're guaranteed to be supplying ints in the
|
||||
* specified vector, consider using {@link getBlockAt} instead for better performance.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate)
|
||||
* @param bool $addToCache Whether to cache the block object created by this method call.
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlock(Vector3 $pos, bool $cached = true, bool $addToCache = true) : Block{
|
||||
return $this->getBlockAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z), $cached, $addToCache);
|
||||
@@ -1374,13 +1274,8 @@ class World implements ChunkManager{
|
||||
* 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.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
* @param bool $cached Whether to use the block cache for getting the block (faster, but may be inaccurate)
|
||||
* @param bool $addToCache Whether to cache the block object created by this method call.
|
||||
*
|
||||
* @return Block
|
||||
*/
|
||||
public function getBlockAt(int $x, int $y, int $z, bool $cached = true, bool $addToCache = true) : Block{
|
||||
$fullState = 0;
|
||||
@@ -1428,10 +1323,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Sets the block at the given Vector3 coordinates.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param Block $block
|
||||
* @param bool $update
|
||||
*
|
||||
* @throws \InvalidArgumentException if the position is out of the world bounds
|
||||
*/
|
||||
public function setBlock(Vector3 $pos, Block $block, bool $update = true) : void{
|
||||
@@ -1444,12 +1335,6 @@ class World implements ChunkManager{
|
||||
* 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.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
* @param Block $block
|
||||
* @param bool $update
|
||||
*
|
||||
* @throws \InvalidArgumentException if the position is out of the world bounds
|
||||
*/
|
||||
public function setBlockAt(int $x, int $y, int $z, Block $block, bool $update = true) : void{
|
||||
@@ -1495,12 +1380,7 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Vector3 $source
|
||||
* @param Item $item
|
||||
* @param Vector3 $motion
|
||||
* @param int $delay
|
||||
*
|
||||
* @return ItemEntity|null
|
||||
*/
|
||||
public function dropItem(Vector3 $source, Item $item, ?Vector3 $motion = null, int $delay = 10) : ?ItemEntity{
|
||||
if($item->isNull()){
|
||||
@@ -1523,9 +1403,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Drops XP orbs into the world for the specified amount, splitting the amount into several orbs if necessary.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param int $amount
|
||||
*
|
||||
* @return ExperienceOrb[]
|
||||
*/
|
||||
public function dropExperience(Vector3 $pos, int $amount) : array{
|
||||
@@ -1554,12 +1431,8 @@ class World implements ChunkManager{
|
||||
* 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.
|
||||
*
|
||||
* @param Vector3 $vector
|
||||
* @param Item $item reference parameter (if null, can break anything)
|
||||
* @param Player $player
|
||||
* @param bool $createParticles
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function useBreakOn(Vector3 $vector, Item &$item = null, ?Player $player = null, bool $createParticles = false) : bool{
|
||||
$vector = $vector->floor();
|
||||
@@ -1650,14 +1523,8 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Uses a item on a position and face, placing it or activating the block
|
||||
*
|
||||
* @param Vector3 $vector
|
||||
* @param Item $item
|
||||
* @param int $face
|
||||
* @param Vector3|null $clickVector
|
||||
* @param Player|null $player default null
|
||||
* @param bool $playSound Whether to play a block-place sound if the block was placed successfully.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function useItemOn(Vector3 $vector, Item &$item, int $face, ?Vector3 $clickVector = null, ?Player $player = null, bool $playSound = false) : bool{
|
||||
$blockClicked = $this->getBlock($vector);
|
||||
@@ -1771,11 +1638,6 @@ class World implements ChunkManager{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $entityId
|
||||
*
|
||||
* @return Entity|null
|
||||
*/
|
||||
public function getEntity(int $entityId) : ?Entity{
|
||||
return $this->entities[$entityId] ?? null;
|
||||
}
|
||||
@@ -1792,9 +1654,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the entities colliding the current one inside the AxisAlignedBB
|
||||
*
|
||||
* @param AxisAlignedBB $bb
|
||||
* @param Entity|null $entity
|
||||
*
|
||||
* @return Entity[]
|
||||
*/
|
||||
public function getCollidingEntities(AxisAlignedBB $bb, ?Entity $entity = null) : array{
|
||||
@@ -1827,7 +1686,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the entities near the current one inside the AxisAlignedBB
|
||||
*
|
||||
* @param AxisAlignedBB $bb
|
||||
* @param Entity $entity
|
||||
*
|
||||
* @return Entity[]
|
||||
@@ -1859,8 +1717,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the closest Entity to the specified position, within the given radius.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param float $maxDistance
|
||||
* @param string $entityType Class of entity to use for instanceof
|
||||
* @param bool $includeDead Whether to include entitites which are dead
|
||||
*
|
||||
@@ -1921,10 +1777,6 @@ class World implements ChunkManager{
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
public function getTile(Vector3 $pos) : ?Tile{
|
||||
return $this->getTileAt((int) floor($pos->x), (int) floor($pos->y), (int) floor($pos->z));
|
||||
@@ -1932,12 +1784,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the tile at the specified x,y,z coordinates, or null if it does not exist.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return Tile|null
|
||||
*/
|
||||
public function getTileAt(int $x, int $y, int $z) : ?Tile{
|
||||
return ($chunk = $this->getChunk($x >> 4, $z >> 4)) !== null ? $chunk->getTile($x & 0x0f, $y, $z & 0x0f) : null;
|
||||
@@ -1946,10 +1792,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Gets the raw block skylight level
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int 0-15
|
||||
*/
|
||||
public function getBlockSkyLightAt(int $x, int $y, int $z) : int{
|
||||
@@ -1959,41 +1801,20 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Gets the raw block light level
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int 0-15
|
||||
*/
|
||||
public function getBlockLightAt(int $x, int $y, int $z) : int{
|
||||
return $this->getChunk($x >> 4, $z >> 4, true)->getBlockLight($x & 0x0f, $y, $z & 0x0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBiomeId(int $x, int $z) : int{
|
||||
return $this->getChunk($x >> 4, $z >> 4, true)->getBiomeId($x & 0x0f, $z & 0x0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return Biome
|
||||
*/
|
||||
public function getBiome(int $x, int $z) : Biome{
|
||||
return Biome::getBiome($this->getBiomeId($x, $z));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
* @param int $biomeId
|
||||
*/
|
||||
public function setBiomeId(int $x, int $z, int $biomeId) : void{
|
||||
$this->getChunk($x >> 4, $z >> 4, true)->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId);
|
||||
}
|
||||
@@ -2009,11 +1830,7 @@ class World implements ChunkManager{
|
||||
* Returns the chunk at the specified X/Z coordinates. If the chunk is not loaded, attempts to (synchronously!!!)
|
||||
* load it.
|
||||
*
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param bool $create Whether to create an empty chunk as a placeholder if the chunk does not exist
|
||||
*
|
||||
* @return Chunk|null
|
||||
*/
|
||||
public function getChunk(int $chunkX, int $chunkZ, bool $create = false) : ?Chunk{
|
||||
if(isset($this->chunks[$index = World::chunkHash($chunkX, $chunkZ)])){
|
||||
@@ -2027,11 +1844,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the chunk containing the given Vector3 position.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
* @param bool $create
|
||||
*
|
||||
* @return null|Chunk
|
||||
*/
|
||||
public function getChunkAtPosition(Vector3 $pos, bool $create = false) : ?Chunk{
|
||||
return $this->getChunk($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4, $create);
|
||||
@@ -2040,9 +1852,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the chunks adjacent to the specified chunk.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return (Chunk|null)[]
|
||||
*/
|
||||
public function getAdjacentChunks(int $x, int $z) : array{
|
||||
@@ -2109,9 +1918,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
* @param Chunk|null $chunk
|
||||
* @param bool $deleteEntitiesAndTiles Whether to delete entities and tiles on the old chunk, or transfer them to the new one
|
||||
*/
|
||||
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk, bool $deleteEntitiesAndTiles = true) : void{
|
||||
@@ -2168,9 +1974,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Gets the highest block Y value at a specific $x and $z
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return int 0-255
|
||||
*/
|
||||
public function getHighestBlockAt(int $x, int $z) : int{
|
||||
@@ -2179,42 +1982,20 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns whether the given position is in a loaded area of terrain.
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isInLoadedTerrain(Vector3 $pos) : bool{
|
||||
return $this->isChunkLoaded($pos->getFloorX() >> 4, $pos->getFloorZ() >> 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isChunkLoaded(int $x, int $z) : bool{
|
||||
return isset($this->chunks[World::chunkHash($x, $z)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isChunkGenerated(int $x, int $z) : bool{
|
||||
$chunk = $this->getChunk($x, $z);
|
||||
return $chunk !== null ? $chunk->isGenerated() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isChunkPopulated(int $x, int $z) : bool{
|
||||
$chunk = $this->getChunk($x, $z);
|
||||
return $chunk !== null ? $chunk->isPopulated() : false;
|
||||
@@ -2222,8 +2003,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns a Position pointing to the spawn
|
||||
*
|
||||
* @return Position
|
||||
*/
|
||||
public function getSpawnLocation() : Position{
|
||||
return Position::fromObject($this->provider->getWorldData()->getSpawn(), $this);
|
||||
@@ -2231,8 +2010,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Sets the world spawn location
|
||||
*
|
||||
* @param Vector3 $pos
|
||||
*/
|
||||
public function setSpawnLocation(Vector3 $pos) : void{
|
||||
$previousSpawn = $this->getSpawnLocation();
|
||||
@@ -2241,8 +2018,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entity $entity
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addEntity(Entity $entity) : void{
|
||||
@@ -2262,8 +2037,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Removes the entity from the world index
|
||||
*
|
||||
* @param Entity $entity
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function removeEntity(Entity $entity) : void{
|
||||
@@ -2281,8 +2054,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tile $tile
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addTile(Tile $tile) : void{
|
||||
@@ -2308,8 +2079,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Tile $tile
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function removeTile(Tile $tile) : void{
|
||||
@@ -2329,12 +2098,6 @@ class World implements ChunkManager{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isChunkInUse(int $x, int $z) : bool{
|
||||
return isset($this->chunkLoaders[$index = World::chunkHash($x, $z)]) and count($this->chunkLoaders[$index]) > 0;
|
||||
}
|
||||
@@ -2342,8 +2105,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Attempts to load a chunk from the world provider (if not already loaded).
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $z
|
||||
* @param bool $create Whether to create an empty chunk to load if the chunk cannot be loaded from disk.
|
||||
*
|
||||
* @return bool if loading the chunk was successful
|
||||
@@ -2473,11 +2234,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns whether the chunk at the specified coordinates is a spawn chunk
|
||||
*
|
||||
* @param int $X
|
||||
* @param int $Z
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSpawnChunk(int $X, int $Z) : bool{
|
||||
$spawn = $this->getSpawnLocation();
|
||||
@@ -2487,11 +2243,6 @@ class World implements ChunkManager{
|
||||
return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Vector3|null $spawn
|
||||
*
|
||||
* @return Position
|
||||
*/
|
||||
public function getSafeSpawn(?Vector3 $spawn = null) : Position{
|
||||
if(!($spawn instanceof Vector3) or $spawn->y < 1){
|
||||
$spawn = $this->getSpawnLocation();
|
||||
@@ -2534,8 +2285,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Gets the current time
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTime() : int{
|
||||
return $this->time;
|
||||
@@ -2543,8 +2292,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the current time of day
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getTimeOfDay() : int{
|
||||
return $this->time % self::TIME_FULL;
|
||||
@@ -2553,8 +2300,6 @@ class World implements ChunkManager{
|
||||
/**
|
||||
* Returns the World display name.
|
||||
* WARNING: This is NOT guaranteed to be unique. Multiple worlds at runtime may share the same display name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName() : string{
|
||||
return $this->displayName;
|
||||
@@ -2562,8 +2307,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Returns the World folder name. This will not change at runtime and will be unique to a world per runtime.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFolderName() : string{
|
||||
return $this->folderName;
|
||||
@@ -2571,8 +2314,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Sets the current time on the world
|
||||
*
|
||||
* @param int $time
|
||||
*/
|
||||
public function setTime(int $time) : void{
|
||||
$this->time = $time;
|
||||
@@ -2597,8 +2338,6 @@ class World implements ChunkManager{
|
||||
|
||||
/**
|
||||
* Gets the world seed
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSeed() : int{
|
||||
return $this->provider->getWorldData()->getSeed();
|
||||
@@ -2608,16 +2347,10 @@ class World implements ChunkManager{
|
||||
return $this->worldHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDifficulty() : int{
|
||||
return $this->provider->getWorldData()->getDifficulty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $difficulty
|
||||
*/
|
||||
public function setDifficulty(int $difficulty) : void{
|
||||
if($difficulty < 0 or $difficulty > 3){
|
||||
throw new \InvalidArgumentException("Invalid difficulty level $difficulty");
|
||||
|
Reference in New Issue
Block a user