From ad7acb93b62c7eb0a49bf092ef5006deb321d543 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Fri, 5 Sep 2014 11:16:24 +0200 Subject: [PATCH] Added cactus neighbour block check --- src/pocketmine/block/Cactus.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/block/Cactus.php b/src/pocketmine/block/Cactus.php index 00a7ae652..98ef2e61b 100644 --- a/src/pocketmine/block/Cactus.php +++ b/src/pocketmine/block/Cactus.php @@ -52,7 +52,17 @@ class Cactus extends Transparent{ $this->getLevel()->setBlock($this, new Air(), false); $this->getLevel()->dropItem($this, Item::get($this->id)); - return Level::BLOCK_UPDATE_NORMAL; + return; + }else{ + for($side = 2; $side <= 5; ++$side){ + $b = $this->getSide($side); + if(!$b->isFlowable){ + $this->getLevel()->setBlock($this, new Air(), false); + $this->getLevel()->dropItem($this, Item::get($this->id)); + + return; + } + } } }elseif($type === Level::BLOCK_UPDATE_RANDOM){ if($this->getSide(0)->getID() !== self::CACTUS){ @@ -60,18 +70,18 @@ class Cactus extends Transparent{ for($y = 1; $y < 3; ++$y){ $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); if($b->getID() === self::AIR){ - $this->getLevel()->setBlock($b, new Cactus(), true, true); + $this->getLevel()->setBlock($b, new Cactus(), true); break; } } $this->meta = 0; - $this->getLevel()->setBlock($this, $this, false); + $this->getLevel()->setBlock($this, $this); }else{ ++$this->meta; - $this->getLevel()->setBlock($this, $this, false); + $this->getLevel()->setBlock($this, $this); } - return Level::BLOCK_UPDATE_RANDOM; + return; } }