Fixed bottom bed offset

This commit is contained in:
Shoghi Cervantes 2013-09-05 22:58:49 +02:00
parent 08d93fa021
commit 41b1a0f991
2 changed files with 26 additions and 2 deletions

View File

@ -301,7 +301,7 @@ class Player{
} }
} }
$this->isSleeping = $pos; $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){ if($this->entity instanceof Entity){
$this->entity->updateMetadata(); $this->entity->updateMetadata();
} }

View File

@ -33,7 +33,31 @@ class BedBlock extends TransparentBlock{
)); ));
return true; 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( $player->dataPacket(MC_CLIENT_MESSAGE, array(
"message" => "This bed is occupied" "message" => "This bed is occupied"
)); ));