From 3e87d1927d263ff415122fafec5c48bdea9e157a Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Mon, 4 Feb 2013 19:08:31 +0100 Subject: [PATCH] Cactus Placement --- src/API/BlockAPI.php | 16 ---------------- src/classes/material/block/plant/Cactus.php | 17 +++++++++++++++++ src/classes/material/block/plant/Sugarcane.php | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 1126043cb..ff0d16a4a 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -283,14 +283,6 @@ class BlockAPI{ "title" => "Furnace", )); break; - case 6: - if($data["block"] === 351 and $data["meta"] === 0x0F){ //Bonemeal - $s = new SaplingBlock($target[1] & 0x03); - $s->position(new Vector3($target[2][0], $target[2][1], $target[2][2])); - $s->onActivate($this->server->api->level, new Item($data["block"], $data["meta"]), $entity->player); - $cancelPlace = true; - } - break; default: $cancelPlace = true; break; @@ -341,14 +333,6 @@ class BlockAPI{ $data2["z"] = $next[2][2]; $this->server->handle("player.block.place", $data2); break; - case 59://Seeds - case 105: - $blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]); - if($blockDown[0] !== 60){ - return false; - } - $data["meta"] = 0; - break; case 81: //Cactus $blockDown = $this->server->api->level->getBlock($data["x"], $data["y"] - 1, $data["z"]); $block0 = $this->server->api->level->getBlock($data["x"], $data["y"], $data["z"] + 1); diff --git a/src/classes/material/block/plant/Cactus.php b/src/classes/material/block/plant/Cactus.php index c8a9e875f..16f7498d3 100644 --- a/src/classes/material/block/plant/Cactus.php +++ b/src/classes/material/block/plant/Cactus.php @@ -30,4 +30,21 @@ class CactusBlock extends TransparentBlock{ parent::__construct(CACTUS, 0, "Cactus"); } + 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->getID() === SAND or $down->getID() === CACTUS){ + $block0 = $level->getBlockFace($block, 2); + $block1 = $level->getBlockFace($block, 3); + $block2 = $level->getBlockFace($block, 4); + $block3 = $level->getBlockFace($block, 5); + if($block0->isFlowable === true and $block1->isFlowable === true and $block2->isFlowable === true and $block3->isFlowable === true){ + $level->setBlock($block, $this->id, 0); + return true; + } + } + } + return false; + } + } \ No newline at end of file diff --git a/src/classes/material/block/plant/Sugarcane.php b/src/classes/material/block/plant/Sugarcane.php index 132d3bf06..e40e19fb9 100644 --- a/src/classes/material/block/plant/Sugarcane.php +++ b/src/classes/material/block/plant/Sugarcane.php @@ -42,7 +42,7 @@ class SugarcaneBlock extends TransparentBlock{ if($down->getID() === SUGARCANE_BLOCK){ $level->setBlock($block, $this->id, 0); return true; - }elseif($down->getID() === 2 or $down->getID() === 3 or $down->getID() === 12){ + }elseif($down->getID() === GRASS or $down->getID() === DIRT or $down->getID() === SAND){ $block0 = $level->getBlockFace($down, 2); $block1 = $level->getBlockFace($down, 3); $block2 = $level->getBlockFace($down, 4);