From 388f5c2c91219120dedc8d91b0afa79d1a30fe13 Mon Sep 17 00:00:00 2001 From: matcracker Date: Sat, 18 Apr 2015 15:21:25 +0200 Subject: [PATCH] Added flowers compatible with MCPE 0.11. Signed-off-by: Michael Yoo --- src/pocketmine/block/Block.php | 5 ++-- .../block/{Poppy.php => Flower.php} | 28 +++++++++++++++++-- src/pocketmine/item/Item.php | 22 +++++++-------- 3 files changed, 37 insertions(+), 18 deletions(-) rename src/pocketmine/block/{Poppy.php => Flower.php} (68%) diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index c3c642400..463fdc21a 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -84,8 +84,7 @@ class Block extends Position implements Metadatable{ const DEAD_BUSH = 32; const WOOL = 35; const DANDELION = 37; - const ROSE = 38; - const POPPY = 38; + const RED_FLOWER = 38; const BROWN_MUSHROOM = 39; const RED_MUSHROOM = 40; const GOLD_BLOCK = 41; @@ -334,7 +333,7 @@ class Block extends Position implements Metadatable{ self::$list[self::DEAD_BUSH] = DeadBush::class; self::$list[self::WOOL] = Wool::class; self::$list[self::DANDELION] = Dandelion::class; - self::$list[self::POPPY] = Poppy::class; + self::$list[self::RED_FLOWER] = Flower::class; self::$list[self::BROWN_MUSHROOM] = BrownMushroom::class; self::$list[self::RED_MUSHROOM] = RedMushroom::class; self::$list[self::GOLD_BLOCK] = Gold::class; diff --git a/src/pocketmine/block/Poppy.php b/src/pocketmine/block/Flower.php similarity index 68% rename from src/pocketmine/block/Poppy.php rename to src/pocketmine/block/Flower.php index 0cbd5b651..7dd378e70 100644 --- a/src/pocketmine/block/Poppy.php +++ b/src/pocketmine/block/Flower.php @@ -25,16 +25,38 @@ use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\Player; -class Poppy extends Flowable{ +class Flower extends Flowable{ + const POPPY = 0; + const BLUE_ORCHID = 1; + const ALLIUM = 2; + const AZURE_BLUET = 3; + const RED_TULIP = 4; + const ORANGE_TULIP = 5; + const WHITE_TULIP = 6; + const PINK_TULIP = 7; + const OXEYE_DAISY = 8; - protected $id = self::POPPY; + protected $id = self::RED_FLOWER; public function __construct($meta = 0){ $this->meta = $meta; + } public function getName(){ - return "Poppy"; + static $names = [ + self::POPPY => "Poppy", + self::BLUE_ORCHID => "Blue Orchid", + self::ALLIUM => "Allium", + self::AZURE_BLUET => "Azure Bluet", + self::RED_TULIP => "Red Tulip", + self::ORANGE_TULIP => "Orange Tulip", + self::WHITE_TULIP => "White Tulip", + self::PINK_TULIP => "Pink Tulip", + self::OXEYE_DAISY => "Oxeye Daisy", + 9 => "Unknown Flower", + ]; + return $names[$this->meta & 0x09]; } diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index d1fb775ae..c14fdd97d 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -78,8 +78,7 @@ class Item{ const DEAD_BUSH = 32; const WOOL = 35; const DANDELION = 37; - const ROSE = 38; - const POPPY = 38; + const RED_FLOWER = 38; const BROWN_MUSHROOM = 39; const RED_MUSHROOM = 40; const GOLD_BLOCK = 41; @@ -499,7 +498,6 @@ class Item{ self::initCreativeItems(); } - private static $creative = []; private static function initCreativeItems(){ @@ -645,15 +643,15 @@ class Item{ self::addCreativeItem(Item::get(Item::FURNACE, 0)); self::addCreativeItem(Item::get(Item::END_PORTAL, 0)); self::addCreativeItem(Item::get(Item::DANDELION, 0)); - self::addCreativeItem(Item::get(Item::POPPY, 0)); - //TODO: blue orchid - //TODO: Allium - //TODO: Azure Bluet - //TODO: Red Tulip - //TODO: Orange Tulip - //TODO: White Tulip - //TODO: Pink Tulip - //TODO: Oxeye Daisy + self::addCreativeItem(Item::get(Item::RED_FLOWER, 0)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 1)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 2)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 3)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 4)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 5)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 6)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 7)); + self::addCreativeItem(Item::get(Item::RED_FLOWER, 8)); //TODO: Lilac //TODO: Double Tallgrass //TODO: Large Fern