Refactor Block & Tile: getPos() to getPosition() (#4395)

this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
This commit is contained in:
SalmonDE
2021-08-23 15:01:32 +02:00
committed by GitHub
parent 22316976fa
commit 7fd712c1ff
93 changed files with 402 additions and 402 deletions

View File

@ -64,7 +64,7 @@ class Farmland extends Transparent{
public function onNearbyBlockChange() : void{
if($this->getSide(Facing::UP)->isSolid()){
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::DIRT());
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::DIRT());
}
}
@ -76,24 +76,24 @@ class Farmland extends Transparent{
if(!$this->canHydrate()){
if($this->wetness > 0){
$this->wetness--;
$this->pos->getWorld()->setBlock($this->pos, $this, false);
$this->position->getWorld()->setBlock($this->position, $this, false);
}else{
$this->pos->getWorld()->setBlock($this->pos, VanillaBlocks::DIRT());
$this->position->getWorld()->setBlock($this->position, VanillaBlocks::DIRT());
}
}elseif($this->wetness < 7){
$this->wetness = 7;
$this->pos->getWorld()->setBlock($this->pos, $this, false);
$this->position->getWorld()->setBlock($this->position, $this, false);
}
}
protected function canHydrate() : bool{
//TODO: check rain
$start = $this->pos->add(-4, 0, -4);
$end = $this->pos->add(4, 1, 4);
$start = $this->position->add(-4, 0, -4);
$end = $this->position->add(4, 1, 4);
for($y = $start->y; $y <= $end->y; ++$y){
for($z = $start->z; $z <= $end->z; ++$z){
for($x = $start->x; $x <= $end->x; ++$x){
if($this->pos->getWorld()->getBlockAt($x, $y, $z) instanceof Water){
if($this->position->getWorld()->getBlockAt($x, $y, $z) instanceof Water){
return true;
}
}