mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Make use of Facing::rotateY() to reduce boilerplate
This commit is contained in:
@ -74,7 +74,7 @@ class Anvil extends Fallable{
|
||||
}
|
||||
|
||||
public function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()->squash(Facing::axis(Facing::rotate($this->facing, Facing::AXIS_Y, false)), 1 / 8);
|
||||
return AxisAlignedBB::one()->squash(Facing::axis(Facing::rotateY($this->facing, false)), 1 / 8);
|
||||
}
|
||||
|
||||
public function onActivate(Item $item, Player $player = null) : bool{
|
||||
@ -87,7 +87,7 @@ class Anvil extends Fallable{
|
||||
|
||||
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||
if($player !== null){
|
||||
$this->facing = Facing::rotate($player->getHorizontalFacing(), Facing::AXIS_Y, true);
|
||||
$this->facing = Facing::rotateY($player->getHorizontalFacing(), true);
|
||||
}
|
||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||
}
|
||||
|
@ -78,8 +78,8 @@ class Chest extends Transparent{
|
||||
}
|
||||
|
||||
foreach([
|
||||
Facing::rotate($player->getHorizontalFacing(), Facing::AXIS_Y, false),
|
||||
Facing::rotate($player->getHorizontalFacing(), Facing::AXIS_Y, true)
|
||||
Facing::rotateY($player->getHorizontalFacing(), false),
|
||||
Facing::rotateY($player->getHorizontalFacing(), true)
|
||||
] as $side){
|
||||
$c = $this->getSide($side);
|
||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
||||
|
@ -75,7 +75,7 @@ class CocoaBlock extends Transparent{
|
||||
|
||||
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||
return AxisAlignedBB::one()
|
||||
->squash(Facing::axis(Facing::rotate($this->facing, Facing::AXIS_Y, true)), (6 - $this->age) / 16) //sides
|
||||
->squash(Facing::axis(Facing::rotateY($this->facing, true)), (6 - $this->age) / 16) //sides
|
||||
->trim(Facing::DOWN, (7 - $this->age * 2) / 16)
|
||||
->trim(Facing::UP, 0.25)
|
||||
->trim(Facing::opposite($this->facing), 1 / 16) //gap between log and pod
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user