mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 20:07:09 +00:00
Some refactoring to allow for light updates to be executed asynchronously
This commit is contained in:
parent
0cf3914f5d
commit
8919d4a372
@ -68,6 +68,48 @@ interface ChunkManager{
|
||||
*/
|
||||
public function setBlockDataAt(int $x, int $y, int $z, int $data);
|
||||
|
||||
/**
|
||||
* Returns the raw block light level
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockLightAt(int $x, int $y, int $z) : int;
|
||||
|
||||
/**
|
||||
* Sets the raw block light level
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
* @param int $level
|
||||
*/
|
||||
public function setBlockLightAt(int $x, int $y, int $z, int $level);
|
||||
|
||||
/**
|
||||
* Returns the highest amount of sky light can reach the specified coordinates.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockSkyLightAt(int $x, int $y, int $z) : int;
|
||||
|
||||
/**
|
||||
* Sets the raw block sky light level.
|
||||
*
|
||||
* @param int $x
|
||||
* @param int $y
|
||||
* @param int $z
|
||||
* @param int $level
|
||||
*/
|
||||
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level);
|
||||
|
||||
/**
|
||||
* @param int $chunkX
|
||||
* @param int $chunkZ
|
||||
|
@ -74,6 +74,8 @@ use pocketmine\level\generator\GeneratorRegisterTask;
|
||||
use pocketmine\level\generator\GeneratorUnregisterTask;
|
||||
use pocketmine\level\generator\LightPopulationTask;
|
||||
use pocketmine\level\generator\PopulationTask;
|
||||
use pocketmine\level\light\BlockLightUpdate;
|
||||
use pocketmine\level\light\SkyLightUpdate;
|
||||
use pocketmine\level\particle\DestroyBlockParticle;
|
||||
use pocketmine\level\particle\Particle;
|
||||
use pocketmine\level\sound\Sound;
|
||||
@ -92,7 +94,6 @@ use pocketmine\nbt\tag\ShortTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\DataPacket;
|
||||
use pocketmine\network\mcpe\protocol\FullChunkDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveEntityPacket;
|
||||
@ -104,7 +105,6 @@ use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\tile\Chest;
|
||||
use pocketmine\tile\Tile;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
|
||||
|
@ -47,7 +47,7 @@ class SimpleChunkManager implements ChunkManager{
|
||||
*/
|
||||
public function getBlockIdAt(int $x, int $y, int $z) : int{
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
return $chunk->getBlockId($x & 0xf, $y & Level::Y_MASK, $z & 0xf);
|
||||
return $chunk->getBlockId($x & 0xf, $y, $z & 0xf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -62,7 +62,7 @@ class SimpleChunkManager implements ChunkManager{
|
||||
*/
|
||||
public function setBlockIdAt(int $x, int $y, int $z, int $id){
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
$chunk->setBlockId($x & 0xf, $y & Level::Y_MASK, $z & 0xf, $id);
|
||||
$chunk->setBlockId($x & 0xf, $y, $z & 0xf, $id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ class SimpleChunkManager implements ChunkManager{
|
||||
*/
|
||||
public function getBlockDataAt(int $x, int $y, int $z) : int{
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
return $chunk->getBlockData($x & 0xf, $y & Level::Y_MASK, $z & 0xf);
|
||||
return $chunk->getBlockData($x & 0xf, $y, $z & 0xf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -92,7 +92,35 @@ class SimpleChunkManager implements ChunkManager{
|
||||
*/
|
||||
public function setBlockDataAt(int $x, int $y, int $z, int $data){
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
$chunk->setBlockData($x & 0xf, $y & Level::Y_MASK, $z & 0xf, $data);
|
||||
$chunk->setBlockData($x & 0xf, $y, $z & 0xf, $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockLightAt(int $x, int $y, int $z) : int{
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
return $chunk->getBlockLight($x & 0xf, $y, $z & 0xf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function setBlockLightAt(int $x, int $y, int $z, int $level){
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
$chunk->setBlockLight($x & 0xf, $y, $z & 0xf, $level);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBlockSkyLightAt(int $x, int $y, int $z) : int{
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
return $chunk->getBlockSkyLight($x & 0xf, $y, $z & 0xf);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){
|
||||
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
|
||||
$chunk->setBlockSkyLight($x & 0xf, $y, $z & 0xf, $level);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level;
|
||||
|
||||
namespace pocketmine\level\light;
|
||||
|
||||
class BlockLightUpdate extends LightUpdate{
|
||||
|
@ -21,15 +21,16 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level;
|
||||
|
||||
namespace pocketmine\level\light;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\level\ChunkManager;
|
||||
use pocketmine\level\Level;
|
||||
|
||||
//TODO: make light updates asynchronous
|
||||
abstract class LightUpdate{
|
||||
|
||||
/** @var Level */
|
||||
/** @var ChunkManager */
|
||||
protected $level;
|
||||
|
||||
/** @var \SplQueue */
|
||||
@ -42,7 +43,7 @@ abstract class LightUpdate{
|
||||
/** @var bool[] */
|
||||
protected $removalVisited = [];
|
||||
|
||||
public function __construct(Level $level){
|
||||
public function __construct(ChunkManager $level){
|
||||
$this->level = $level;
|
||||
$this->removalQueue = new \SplQueue();
|
||||
$this->spreadQueue = new \SplQueue();
|
@ -21,8 +21,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\level;
|
||||
|
||||
namespace pocketmine\level\light;
|
||||
|
||||
class SkyLightUpdate extends LightUpdate{
|
||||
|
Loading…
x
Reference in New Issue
Block a user