mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-20 10:00:31 +00:00
Grass: remove premature optimization
this is reading full-block from the chunk every access, which is slower than accessing the level block-cache.
This commit is contained in:
parent
797aabdf15
commit
242c7e3777
@ -66,7 +66,7 @@ class Grass extends Solid{
|
|||||||
|
|
||||||
public function onRandomTick() : void{
|
public function onRandomTick() : void{
|
||||||
$lightAbove = $this->level->getFullLightAt($this->x, $this->y + 1, $this->z);
|
$lightAbove = $this->level->getFullLightAt($this->x, $this->y + 1, $this->z);
|
||||||
if($lightAbove < 4 and BlockFactory::$lightFilter[$this->level->getFullBlock($this->x, $this->y + 1, $this->z)] >= 3){ //2 plus 1 standard filter amount
|
if($lightAbove < 4 and $this->level->getBlockAt($this->x, $this->y + 1, $this->z)->getLightFilter() >= 2){
|
||||||
//grass dies
|
//grass dies
|
||||||
$ev = new BlockSpreadEvent($this, $this, BlockFactory::get(Block::DIRT));
|
$ev = new BlockSpreadEvent($this, $this, BlockFactory::get(Block::DIRT));
|
||||||
$ev->call();
|
$ev->call();
|
||||||
@ -85,7 +85,7 @@ class Grass extends Solid{
|
|||||||
$b->getId() !== Block::DIRT or
|
$b->getId() !== Block::DIRT or
|
||||||
$b->getDamage() === 1 or //coarse dirt
|
$b->getDamage() === 1 or //coarse dirt
|
||||||
$this->level->getFullLightAt($x, $y + 1, $z) < 4 or
|
$this->level->getFullLightAt($x, $y + 1, $z) < 4 or
|
||||||
BlockFactory::$lightFilter[$this->level->getFullBlock($x, $y + 1, $z)] >= 3
|
$this->level->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||||
){
|
){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user