Make use of Facing::rotateY() to reduce boilerplate

This commit is contained in:
Dylan K. Taylor
2018-12-07 10:49:12 +00:00
parent 1cac2b098e
commit 8dbeda69a7
7 changed files with 21 additions and 21 deletions

View File

@ -92,7 +92,7 @@ abstract class Door extends Transparent{
protected function recalculateBoundingBox() : ?AxisAlignedBB{
return AxisAlignedBB::one()
->extend(Facing::UP, 1)
->trim($this->open ? Facing::rotate($this->facing, Facing::AXIS_Y, !$this->hingeRight) : $this->facing, 13 / 16);
->trim($this->open ? Facing::rotateY($this->facing, !$this->hingeRight) : $this->facing, 13 / 16);
}
public function onNearbyBlockChange() : void{
@ -113,8 +113,8 @@ abstract class Door extends Transparent{
$this->facing = $player->getHorizontalFacing();
}
$next = $this->getSide(Facing::rotate($this->facing, Facing::AXIS_Y, false));
$next2 = $this->getSide(Facing::rotate($this->facing, Facing::AXIS_Y, true));
$next = $this->getSide(Facing::rotateY($this->facing, false));
$next2 = $this->getSide(Facing::rotateY($this->facing, true));
if($next->isSameType($this) or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
$this->hingeRight = true;