diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index d15fda93..e010e6cb 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -258,7 +258,11 @@ class BlockAPI{ [DYE, 11], [DYE, 10], [DYE, 9], - [DYE, 8] + [DYE, 8], + [DOUBLE_PLANT, 0], + [DOUBLE_PLANT, 1], + [DOUBLE_PLANT, 2], + [DOUBLE_PLANT, 3], ]; private $server; diff --git a/src/material/Block.php b/src/material/Block.php index eb93ac8c..80c83ea9 100755 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -151,6 +151,7 @@ abstract class Block extends Position{ PODZOL => "PodzolBlock", STAINED_CLAY => "StainedClayBlock", LILY_PAD => "LilypadBlock", + DOUBLE_PLANT => "DoubleTallGrass", ); protected $id; protected $meta; diff --git a/src/material/block/plant/DoubleTallGrass.php b/src/material/block/plant/DoubleTallGrass.php new file mode 100644 index 00000000..2b301177 --- /dev/null +++ b/src/material/block/plant/DoubleTallGrass.php @@ -0,0 +1,41 @@ + "Sunflower", + 1 => "Lilac", + 2 => "Tall Grass", + 3 => "Tall Fern", + ]; + public function __construct($meta = 1){ + parent::__construct(DOUBLE_PLANT, $meta, "Tall Grass"); + $this->name = self::$NAMES[$this->meta]; + $this->hardness = 0; + } + + public function onUpdate($type){ + if($type === BLOCK_UPDATE_NORMAL){ //TODO destroy if 2nd block occupied + if($this->getSide(0)->isTransparent === true){//Replace with common break method + $this->level->setBlock($this, new AirBlock(), false, false, true); + return BLOCK_UPDATE_NORMAL; + } + } + return false; + } + + public function getDrops(Item $item, Player $player){ //TODO vanilla? + return []; + } + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $down = $this->getSide(0); + if($down->getID() == 2 or $down->getID() == 3){ //TODO destroy the block above(tested only in creative) + $this->level->setBlock($block, $this, true, false, true); + return true; + } + return false; + } + +} +