mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Position: rename getWorldNonNull() to getWorld(), remove original getWorld()
This commit is contained in:
@ -56,13 +56,13 @@ class Grass extends Opaque{
|
||||
}
|
||||
|
||||
public function onRandomTick() : void{
|
||||
$lightAbove = $this->pos->getWorldNonNull()->getFullLightAt($this->pos->x, $this->pos->y + 1, $this->pos->z);
|
||||
if($lightAbove < 4 and $this->pos->getWorldNonNull()->getBlockAt($this->pos->x, $this->pos->y + 1, $this->pos->z)->getLightFilter() >= 2){
|
||||
$lightAbove = $this->pos->getWorld()->getFullLightAt($this->pos->x, $this->pos->y + 1, $this->pos->z);
|
||||
if($lightAbove < 4 and $this->pos->getWorld()->getBlockAt($this->pos->x, $this->pos->y + 1, $this->pos->z)->getLightFilter() >= 2){
|
||||
//grass dies
|
||||
$ev = new BlockSpreadEvent($this, $this, VanillaBlocks::DIRT());
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->pos->getWorldNonNull()->setBlock($this->pos, $ev->getNewState(), false);
|
||||
$this->pos->getWorld()->setBlock($this->pos, $ev->getNewState(), false);
|
||||
}
|
||||
}elseif($lightAbove >= 9){
|
||||
//try grass spread
|
||||
@ -71,12 +71,12 @@ class Grass extends Opaque{
|
||||
$y = mt_rand($this->pos->y - 3, $this->pos->y + 1);
|
||||
$z = mt_rand($this->pos->z - 1, $this->pos->z + 1);
|
||||
|
||||
$b = $this->pos->getWorldNonNull()->getBlockAt($x, $y, $z);
|
||||
$b = $this->pos->getWorld()->getBlockAt($x, $y, $z);
|
||||
if(
|
||||
!($b instanceof Dirt) or
|
||||
$b instanceof CoarseDirt or
|
||||
$this->pos->getWorldNonNull()->getFullLightAt($x, $y + 1, $z) < 4 or
|
||||
$this->pos->getWorldNonNull()->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||
$this->pos->getWorld()->getFullLightAt($x, $y + 1, $z) < 4 or
|
||||
$this->pos->getWorld()->getBlockAt($x, $y + 1, $z)->getLightFilter() >= 2
|
||||
){
|
||||
continue;
|
||||
}
|
||||
@ -84,7 +84,7 @@ class Grass extends Opaque{
|
||||
$ev = new BlockSpreadEvent($b, $this, VanillaBlocks::GRASS());
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
$this->pos->getWorldNonNull()->setBlock($b->pos, $ev->getNewState(), false);
|
||||
$this->pos->getWorld()->setBlock($b->pos, $ev->getNewState(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -96,17 +96,17 @@ class Grass extends Opaque{
|
||||
}
|
||||
if($item instanceof Fertilizer){
|
||||
$item->pop();
|
||||
TallGrassObject::growGrass($this->pos->getWorldNonNull(), $this->pos, new Random(mt_rand()), 8, 2);
|
||||
TallGrassObject::growGrass($this->pos->getWorld(), $this->pos, new Random(mt_rand()), 8, 2);
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Hoe){
|
||||
$item->applyDamage(1);
|
||||
$this->pos->getWorldNonNull()->setBlock($this->pos, VanillaBlocks::FARMLAND());
|
||||
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::FARMLAND());
|
||||
|
||||
return true;
|
||||
}elseif($item instanceof Shovel and $this->getSide(Facing::UP)->getId() === BlockLegacyIds::AIR){
|
||||
$item->applyDamage(1);
|
||||
$this->pos->getWorldNonNull()->setBlock($this->pos, VanillaBlocks::GRASS_PATH());
|
||||
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::GRASS_PATH());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user