mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 18:32:55 +00:00
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:
@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user