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

@ -59,7 +59,7 @@ abstract class Stair extends Transparent{
public function readStateFromWorld() : void{
parent::readStateFromWorld();
$clockwise = Facing::rotate($this->facing, Facing::AXIS_Y, true);
$clockwise = Facing::rotateY($this->facing, true);
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
$this->shape = $backFacing === $clockwise ? self::SHAPE_OUTER_RIGHT : self::SHAPE_OUTER_LEFT;
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
@ -82,13 +82,13 @@ abstract class Stair extends Transparent{
$topStep->trim(Facing::opposite($this->facing), 0.5);
if($this->shape === self::SHAPE_OUTER_LEFT or $this->shape === self::SHAPE_OUTER_RIGHT){
$topStep->trim(Facing::rotate($this->facing, Facing::AXIS_Y, $this->shape === self::SHAPE_OUTER_LEFT), 0.5);
$topStep->trim(Facing::rotateY($this->facing, $this->shape === self::SHAPE_OUTER_LEFT), 0.5);
}elseif($this->shape === self::SHAPE_INNER_LEFT or $this->shape === self::SHAPE_INNER_RIGHT){
//add an extra cube
$extraCube = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
$bbs[] = $extraCube
->trim($this->facing, 0.5) //avoid overlapping with main step
->trim(Facing::rotate($this->facing, Facing::AXIS_Y, $this->shape === self::SHAPE_INNER_LEFT), 0.5);
->trim(Facing::rotateY($this->facing, $this->shape === self::SHAPE_INNER_LEFT), 0.5);
}
$bbs[] = $topStep;