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:
Dylan K. Taylor 2019-01-14 23:14:22 +00:00
parent 797aabdf15
commit 242c7e3777

View File

@ -66,7 +66,7 @@ class Grass extends Solid{
public function onRandomTick() : void{
$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
$ev = new BlockSpreadEvent($this, $this, BlockFactory::get(Block::DIRT));
$ev->call();
@ -85,7 +85,7 @@ class Grass extends Solid{
$b->getId() !== Block::DIRT or
$b->getDamage() === 1 or //coarse dirt
$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;
}