From 4c2a1c8684c6c6e7c3b4b2caac37fe46e73b96b0 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Mon, 6 Oct 2014 09:34:40 +0200 Subject: [PATCH] Implement crop growth levels properly, fixes #2002, closes #2160 --- src/pocketmine/block/Beetroot.php | 5 ++++- src/pocketmine/block/Carrot.php | 5 ++++- src/pocketmine/block/Potato.php | 5 ++++- src/pocketmine/block/Wheat.php | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/block/Beetroot.php b/src/pocketmine/block/Beetroot.php index c5b606b94..2a04c42aa 100644 --- a/src/pocketmine/block/Beetroot.php +++ b/src/pocketmine/block/Beetroot.php @@ -49,7 +49,10 @@ class Beetroot extends Flowable{ public function onActivate(Item $item, Player $player = null){ if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal - $this->meta = 0x07; + $this->meta += mt_rand(2, 5); + if($this->meta > 7){ + $this->meta = 7; + } $this->getLevel()->setBlock($this, $this, true, true); $item->count--; diff --git a/src/pocketmine/block/Carrot.php b/src/pocketmine/block/Carrot.php index e4b81c9a7..7a92e9746 100644 --- a/src/pocketmine/block/Carrot.php +++ b/src/pocketmine/block/Carrot.php @@ -50,7 +50,10 @@ class Carrot extends Flowable{ public function onActivate(Item $item, Player $player = null){ if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal - $this->meta = 0x07; + $this->meta += mt_rand(2, 5); + if($this->meta > 7){ + $this->meta = 7; + } $this->getLevel()->setBlock($this, $this, true); $item->count--; diff --git a/src/pocketmine/block/Potato.php b/src/pocketmine/block/Potato.php index 146645f01..9e03f4ae2 100644 --- a/src/pocketmine/block/Potato.php +++ b/src/pocketmine/block/Potato.php @@ -50,7 +50,10 @@ class Potato extends Flowable{ public function onActivate(Item $item, Player $player = null){ if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal - $this->meta = 0x07; + $this->meta += mt_rand(2, 5); + if($this->meta > 7){ + $this->meta = 7; + } $this->getLevel()->setBlock($this, $this, true); if(($player->gamemode & 0x01) === 0){ $item->count--; diff --git a/src/pocketmine/block/Wheat.php b/src/pocketmine/block/Wheat.php index d3a34603c..42f323fc0 100644 --- a/src/pocketmine/block/Wheat.php +++ b/src/pocketmine/block/Wheat.php @@ -50,7 +50,10 @@ class Wheat extends Flowable{ public function onActivate(Item $item, Player $player = null){ if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal - $this->meta = 0x07; + $this->meta += mt_rand(2, 5); + if($this->meta > 7){ + $this->meta = 7; + } $this->getLevel()->setBlock($this, $this, true); if(($player->gamemode & 0x01) === 0){ $item->count--;