From 41b1a0f991cc01d01703feae73f6621dd7fc96e4 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Thu, 5 Sep 2013 22:58:49 +0200 Subject: [PATCH] Fixed bottom bed offset --- src/Player.php | 2 +- src/material/block/misc/Bed.php | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Player.php b/src/Player.php index 647879046..9fafff7dc 100644 --- a/src/Player.php +++ b/src/Player.php @@ -301,7 +301,7 @@ class Player{ } } $this->isSleeping = $pos; - $this->teleport(new Position($pos->x + 0.5, $pos->y, $pos->z + 0.5, $this->level)); + $this->teleport(new Position($pos->x + 0.5, $pos->y + 1, $pos->z + 0.5, $this->level), false, false, false, false); if($this->entity instanceof Entity){ $this->entity->updateMetadata(); } diff --git a/src/material/block/misc/Bed.php b/src/material/block/misc/Bed.php index 47fd2ff0a..25fcb82a9 100644 --- a/src/material/block/misc/Bed.php +++ b/src/material/block/misc/Bed.php @@ -33,7 +33,31 @@ class BedBlock extends TransparentBlock{ )); return true; } - if($player->sleepOn($this) === false){ + + $blockNorth = $this->getSide(2); //Gets the blocks around them + $blockSouth = $this->getSide(3); + $blockEast = $this->getSide(5); + $blockWest = $this->getSide(4); + if(($this->meta & 0x08) === 0x08){ //This is the Top part of bed + $b = $this; + }else{ //Bottom Part of Bed + if($blockNorth->getID() === $this->id and ($blockNorth->meta & 0x08) === 0x08){ + $b = $blockNorth; + }elseif($blockSouth->getID() === $this->id and ($blockSouth->meta & 0x08) === 0x08){ + $b = $blockSouth; + }elseif($blockEast->getID() === $this->id and ($blockEast->meta & 0x08) === 0x08){ + $b = $blockEast; + }elseif($blockWest->getID() === $this->id and ($blockWest->meta & 0x08) === 0x08){ + $b = $blockWest; + }else{ + $player->dataPacket(MC_CLIENT_MESSAGE, array( + "message" => "The bed is incomplete" + )); + return true; + } + } + + if($player->sleepOn($b) === false){ $player->dataPacket(MC_CLIENT_MESSAGE, array( "message" => "This bed is occupied" ));