diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 45347512..f354994c 100644 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -322,7 +322,7 @@ class BlockAPI{ 2 => 2, 3 => 5, ); - $next = $this->server->api->level->getBlockFace($block, $face[(($direction + 3) % 4)]); + $next = $level->getBlockFace($block, $face[(($direction + 3) % 4)]); if(!isset(Material::$replaceable[$next[0]])){ return false; } diff --git a/src/classes/material/Item.php b/src/classes/material/Item.php index 9d8081e4..4725f76c 100644 --- a/src/classes/material/Item.php +++ b/src/classes/material/Item.php @@ -35,6 +35,7 @@ class Item{ SIGN => "SignItem", WOODEN_DOOR => "WoodenDoorItem", IRON_DOOR => "IronDoorItem", + BED => "BedItem", ); protected $block; protected $id; diff --git a/src/classes/material/block/misc/Bed.php b/src/classes/material/block/misc/Bed.php index 8f61626d..df2751f9 100644 --- a/src/classes/material/block/misc/Bed.php +++ b/src/classes/material/block/misc/Bed.php @@ -31,4 +31,34 @@ class BedBlock extends TransparentBlock{ $this->isActivable = 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){ + $faces = array( + 0 => 3, + 1 => 4, + 2 => 2, + 3 => 5, + ); + $d = $player->entity->getDirection(); + $next = $level->getBlockFace($block, $faces[(($d + 3) % 4)]); + $downNext = $level->getBlockFace($next, 0); + if($next->isReplaceable === true and $downNext->isTransparent === false){ + $meta = (($d + 3) % 4) & 0x03; + $level->setBlock($block, $this->id, $meta); + $level->setBlock($next, $this->id, $meta | 0x08); + return true; + } + } + } + return false; + } + + public function getDrops(Item $item, Player $player){ + return array( + array(BED, 0, 1), + ); + } + } \ No newline at end of file diff --git a/src/classes/material/item/generic/Bed.php b/src/classes/material/item/generic/Bed.php new file mode 100644 index 00000000..68e6c46f --- /dev/null +++ b/src/classes/material/item/generic/Bed.php @@ -0,0 +1,33 @@ +block = BlockAPI::get(BED_BLOCK); + parent::__construct(BED, 0, $count, "Bed"); + } +} \ No newline at end of file