From 0dc783f285762435fad3397aa2ccd1fe5fcc3ae0 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 24 Nov 2013 15:50:02 +0100 Subject: [PATCH] Added carpets, crafting recipes, placement --- src/constants/BlockIDs.php | 1 + src/material/Block.php | 1 + src/material/block/nonfull/Carpet.php | 67 +++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/material/block/nonfull/Carpet.php diff --git a/src/constants/BlockIDs.php b/src/constants/BlockIDs.php index 542e9e3b4..46804c299 100644 --- a/src/constants/BlockIDs.php +++ b/src/constants/BlockIDs.php @@ -178,6 +178,7 @@ define("WOOD_SLABS", 158); define("WOODEN_SLABS", 158); define("HAY_BALE", 170); +define("CARPET", 171); define("COAL_BLOCK", 173); diff --git a/src/material/Block.php b/src/material/Block.php index 9165cf77b..e2c3960b7 100644 --- a/src/material/Block.php +++ b/src/material/Block.php @@ -134,6 +134,7 @@ abstract class Block extends Position{ WOOD_SLAB => "WoodSlabBlock", HAY_BALE => "HayBaleBlock", + CARPET => "CarpetBlock", COAL_BLOCK => "CoalBlock", diff --git a/src/material/block/nonfull/Carpet.php b/src/material/block/nonfull/Carpet.php new file mode 100644 index 000000000..867f963f9 --- /dev/null +++ b/src/material/block/nonfull/Carpet.php @@ -0,0 +1,67 @@ + "White Carpet", + 1 => "Orange Carpet", + 2 => "Magenta Carpet", + 3 => "Light Blue Carpet", + 4 => "Yellow Carpet", + 5 => "Lime Carpet", + 6 => "Pink Carpet", + 7 => "Gray Carpet", + 8 => "Light Gray Carpet", + 9 => "Cyan Carpet", + 10 => "Purple Carpet", + 11 => "Blue Carpet", + 12 => "Brown Carpet", + 13 => "Green Carpet", + 14 => "Red Carpet", + 15 => "Black Carpet", + ); + $this->name = $names[$this->meta]; + $this->hardness = 0; + $this->isFullBlock = false; + } + + public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ + $down = $this->getSide(0); + if($down->getID() !== AIR){ + $this->level->setBlock($block, $this, true, false, true); + return true; + } + return false; + } + + public function onUpdate($type){ + if($type === BLOCK_UPDATE_NORMAL){ + if($this->getSide(0)->getID() === AIR){ //Replace with common break method + $this->level->setBlock($this, new AirBlock(), true, false, true); + return BLOCK_UPDATE_NORMAL; + } + } + return false; + } + +} \ No newline at end of file