124 if($player !== null){
125 $other = $this->getOtherHalf();
126 $playerPos = $player->getPosition();
128 $player->sendMessage(TextFormat::GRAY .
"This bed is incomplete");
131 }elseif($playerPos->distanceSquared($this->position) > 4 && $playerPos->distanceSquared($other->position) > 4){
132 $player->sendMessage(KnownTranslationFactory::tile_bed_tooFar()->prefix(TextFormat::GRAY));
136 $time = $this->position->getWorld()->getTimeOfDay();
138 $isNight = ($time >= World::TIME_NIGHT && $time < World::TIME_SUNRISE);
141 $player->sendMessage(KnownTranslationFactory::tile_bed_noSleep()->prefix(TextFormat::GRAY));
146 $b = ($this->isHeadPart() ? $this : $other);
149 $player->sendMessage(KnownTranslationFactory::tile_bed_occupied()->prefix(TextFormat::GRAY));
154 $player->sleepOn($b->position);
177 if($this->canBeSupportedAt($blockReplace)){
178 $this->facing = $player !==
null ? $player->getHorizontalFacing() : Facing::NORTH;
180 $next = $this->getSide($this->getOtherHalfSide());
181 if($next->canBeReplaced() && $this->canBeSupportedAt($next)){
182 $nextState = clone $this;
183 $nextState->head =
true;
184 $tx->
addBlock($blockReplace->position, $this)->addBlock($next->position, $nextState);