mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
World: some cleanup to random blocktick registry
This commit is contained in:
parent
ce77e283ab
commit
a2bb6a41d9
@ -235,8 +235,8 @@ class World implements ChunkManager{
|
|||||||
private $chunkTickRadius;
|
private $chunkTickRadius;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
private $chunksPerTick;
|
private $chunksPerTick;
|
||||||
/** @var \SplFixedArray<bool> */
|
/** @var bool[] */
|
||||||
private $randomTickBlocks = null;
|
private $randomTickBlocks = [];
|
||||||
|
|
||||||
/** @var WorldTimings */
|
/** @var WorldTimings */
|
||||||
public $timings;
|
public $timings;
|
||||||
@ -370,17 +370,9 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
$dontTickBlocks = array_fill_keys($this->server->getProperty("chunk-ticking.disable-block-ticking", []), true);
|
$dontTickBlocks = array_fill_keys($this->server->getProperty("chunk-ticking.disable-block-ticking", []), true);
|
||||||
|
|
||||||
$this->randomTickBlocks = new \SplFixedArray(16384);
|
foreach(BlockFactory::getAllKnownStates() as $state){
|
||||||
foreach($this->randomTickBlocks as $i => $null){
|
if(!isset($dontTickBlocks[$state->getId()]) and $state->ticksRandomly()){
|
||||||
$id = $i >> 4;
|
$this->randomTickBlocks[$state->getFullId()] = true;
|
||||||
$meta = $i & 0xf;
|
|
||||||
try{
|
|
||||||
$block = BlockFactory::get($id, $meta); //Make sure it's a copy
|
|
||||||
}catch(\InvalidArgumentException $e){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!isset($dontTickBlocks[$id]) and $block->ticksRandomly()){
|
|
||||||
$this->randomTickBlocks[($id << 4) | $meta] = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,7 +924,10 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRandomTickedBlocks() : \SplFixedArray{
|
/**
|
||||||
|
* @return bool[] fullID => bool
|
||||||
|
*/
|
||||||
|
public function getRandomTickedBlocks() : array{
|
||||||
return $this->randomTickBlocks;
|
return $this->randomTickBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,7 +940,7 @@ class World implements ChunkManager{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function removeRandomTickedBlock(int $id, int $variant = 0){
|
public function removeRandomTickedBlock(int $id, int $variant = 0){
|
||||||
$this->randomTickBlocks[($id << 4) | $variant] = null;
|
unset($this->randomTickBlocks[($id << 4) | $variant]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function tickChunks(){
|
private function tickChunks(){
|
||||||
@ -1002,7 +997,7 @@ class World implements ChunkManager{
|
|||||||
|
|
||||||
$state = $subChunk->getFullBlock($x, $y, $z);
|
$state = $subChunk->getFullBlock($x, $y, $z);
|
||||||
|
|
||||||
if($this->randomTickBlocks[$state]){
|
if(isset($this->randomTickBlocks[$state])){
|
||||||
/** @var Block $block */
|
/** @var Block $block */
|
||||||
$block = BlockFactory::fromFullBlock($state, $this->temporalPosition->setComponents(
|
$block = BlockFactory::fromFullBlock($state, $this->temporalPosition->setComponents(
|
||||||
$chunkX * 16 + $x,
|
$chunkX * 16 + $x,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user