Files
PocketMine-MP/src/player/PlayerChunkLoader.php
Dylan T 946c2fbacc Ticking chunks rewrite (#5689)
This API is much more flexible than the old, allowing any arbitrary set of chunks to be ticked.

These changes also improve the performance of random chunk ticking by almost entirely eliminating the cost of chunk selection. Ticking chunks are now reevaluated when a player moves, instead of every tick.

The system also does not attempt to check the same chunks twice, leading to further improvements.

Overall, the overhead of random chunk selection is reduced anywhere from 80-96%. In practice, this can offer a 5-10% performance gain for servers with sparsely distributed players.
2023-04-11 20:01:19 +01:00

48 lines
1.4 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\player;
use pocketmine\math\Vector3;
use pocketmine\world\TickingChunkLoader;
/**
* @deprecated This class was only needed to implement TickingChunkLoader, which is now deprecated.
* ChunkTicker should be registered on ticking chunks to make them tick instead.
*/
final class PlayerChunkLoader implements TickingChunkLoader{
public function __construct(private Vector3 $currentLocation){}
public function setCurrentLocation(Vector3 $currentLocation) : void{
$this->currentLocation = $currentLocation;
}
public function getX() : float{
return $this->currentLocation->getFloorX();
}
public function getZ() : float{
return $this->currentLocation->getFloorZ();
}
}