From 3ecbe7dbf796f29d144157476bdfbee2a6000fbd Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sun, 3 Feb 2013 20:24:22 +0100 Subject: [PATCH] Added Mushroom placement --- src/API/BlockAPI.php | 17 ----------------- .../material/block/plant/BrownMushroom.php | 10 ++++++++++ .../material/block/plant/RedMushroom.php | 12 +++++++++++- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index a134f9f54..f9ac3a888 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -512,23 +512,6 @@ class BlockAPI{ } /*switch($data["block"]){ - case 6: - if($target[0] === 60){ - break; - } - case 37: - case 38: - if(($target[0] !== 2 and $target[0] !== 3) or $data["face"] !== 1){ - return false; - } - break; - case 39://Mushrooms - case 40: - $blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]); - if(isset(Material::$transparent[$blockDown[0]])){ - return false; - } - break; case 338: case 83: //Sugarcane $data["block"] = 83; diff --git a/src/classes/material/block/plant/BrownMushroom.php b/src/classes/material/block/plant/BrownMushroom.php index 302aca62c..ae6236f5a 100644 --- a/src/classes/material/block/plant/BrownMushroom.php +++ b/src/classes/material/block/plant/BrownMushroom.php @@ -31,4 +31,14 @@ class BrownMushroomBlock extends FlowableBlock{ $this->isFlowable = true; } + public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($block->inWorld === true){ + $down = $level->getBlockFace($block, 0); + if($down->isTransparent === false){ + $level->setBlock($block, $this->id, $this->getMetadata()); + return true; + } + } + return false; + } } \ No newline at end of file diff --git a/src/classes/material/block/plant/RedMushroom.php b/src/classes/material/block/plant/RedMushroom.php index eea6dc3ed..9c45b618a 100644 --- a/src/classes/material/block/plant/RedMushroom.php +++ b/src/classes/material/block/plant/RedMushroom.php @@ -30,5 +30,15 @@ class RedMushroomBlock extends FlowableBlock{ parent::__construct(RED_MUSHROOM, 0, "Red Mushroom"); $this->isFlowable = true; } - + + public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + if($block->inWorld === true){ + $down = $level->getBlockFace($block, 0); + if($down->isTransparent === false){ + $level->setBlock($block, $this->id, $this->getMetadata()); + return true; + } + } + return false; + } } \ No newline at end of file