mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
Fixed fix for flowers, removed corrupted flower state, added proper identifiers that do not collide, added remaining IDs everywhere for consistency, removed magic number for constants, closes #3058
This commit is contained in:
parent
f91a3a2666
commit
c4d63326be
@ -84,6 +84,8 @@ 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;
|
||||
|
@ -23,47 +23,53 @@ namespace pocketmine\block;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\Player;
|
||||
|
||||
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;
|
||||
const TYPE_POPPY = 0;
|
||||
const TYPE_BLUE_ORCHID = 1;
|
||||
const TYPE_ALLIUM = 2;
|
||||
const TYPE_AZURE_BLUET = 3;
|
||||
const TYPE_RED_TULIP = 4;
|
||||
const TYPE_ORANGE_TULIP = 5;
|
||||
const TYPE_WHITE_TULIP = 6;
|
||||
const TYPE_PINK_TULIP = 7;
|
||||
const TYPE_OXEYE_DAISY = 8;
|
||||
|
||||
protected $id = self::RED_FLOWER;
|
||||
|
||||
public function __construct($meta = 0){
|
||||
$this->meta = $meta;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
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",
|
||||
self::TYPE_POPPY => "Poppy",
|
||||
self::TYPE_BLUE_ORCHID => "Blue Orchid",
|
||||
self::TYPE_ALLIUM => "Allium",
|
||||
self::TYPE_AZURE_BLUET => "Azure Bluet",
|
||||
self::TYPE_RED_TULIP => "Red Tulip",
|
||||
self::TYPE_ORANGE_TULIP => "Orange Tulip",
|
||||
self::TYPE_WHITE_TULIP => "White Tulip",
|
||||
self::TYPE_PINK_TULIP => "Pink Tulip",
|
||||
self::TYPE_OXEYE_DAISY => "Oxeye Daisy",
|
||||
9 => "Unknown",
|
||||
10 => "Unknown",
|
||||
11 => "Unknown",
|
||||
12 => "Unknown",
|
||||
13 => "Unknown",
|
||||
14 => "Unknown",
|
||||
15 => "Unknown"
|
||||
];
|
||||
return $names[$this->meta & 0x09];
|
||||
return $names[$this->meta];
|
||||
}
|
||||
|
||||
|
||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||
$down = $this->getSide(0);
|
||||
if($down->getId() === 2 or $down->getId() === 3 or $down->getId() === 60){
|
||||
$this->getLevel()->setBlock($block, $this, true, true);
|
||||
if($down->getId() === Block::GRASS or $down->getId() === Block::DIRT or $down->getId() === Block::FARMLAND){
|
||||
$this->getLevel()->setBlock($block, $this, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -73,7 +79,7 @@ class Flower extends Flowable{
|
||||
|
||||
public function onUpdate($type){
|
||||
if($type === Level::BLOCK_UPDATE_NORMAL){
|
||||
if($this->getSide(0)->isTransparent() === true){
|
||||
if($this->getSide(Vector3::SIDE_DOWN)->isTransparent()){
|
||||
$this->getLevel()->useBreakOn($this);
|
||||
|
||||
return Level::BLOCK_UPDATE_NORMAL;
|
||||
|
@ -25,6 +25,7 @@
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\Flower;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\Squid;
|
||||
use pocketmine\entity\Villager;
|
||||
@ -78,6 +79,8 @@ class Item{
|
||||
const DEAD_BUSH = 32;
|
||||
const WOOL = 35;
|
||||
const DANDELION = 37;
|
||||
const POPPY = 38;
|
||||
const ROSE = 38;
|
||||
const RED_FLOWER = 38;
|
||||
const BROWN_MUSHROOM = 39;
|
||||
const RED_MUSHROOM = 40;
|
||||
@ -643,15 +646,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::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));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_POPPY));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_BLUE_ORCHID));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_ALLIUM));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_AZURE_BLUET));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_RED_TULIP));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_ORANGE_TULIP));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_WHITE_TULIP));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_PINK_TULIP));
|
||||
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_OXEYE_DAISY));
|
||||
//TODO: Lilac
|
||||
//TODO: Double Tallgrass
|
||||
//TODO: Large Fern
|
||||
|
Loading…
x
Reference in New Issue
Block a user