first shot making Block not extend Position

this makes some stuff a lot less pretty, but this seems to be the bare minimum necessary to do this task. It can be enhanced later.
This commit is contained in:
Dylan K. Taylor
2019-08-05 16:44:09 +01:00
parent cf271dab2b
commit 53ab860db5
75 changed files with 337 additions and 325 deletions

View File

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