mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-23 19:34:15 +00:00
HorizontalFacingTrait: use a cheaper check for horizontal facing
This commit is contained in:
parent
2b044195a5
commit
2545897fc2
@ -23,8 +23,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace pocketmine\block\utils;
|
namespace pocketmine\block\utils;
|
||||||
|
|
||||||
|
use pocketmine\math\Axis;
|
||||||
use pocketmine\math\Facing;
|
use pocketmine\math\Facing;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
trait HorizontalFacingTrait{
|
trait HorizontalFacingTrait{
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@ -34,7 +34,8 @@ trait HorizontalFacingTrait{
|
|||||||
|
|
||||||
/** @return $this */
|
/** @return $this */
|
||||||
public function setFacing(int $facing) : self{
|
public function setFacing(int $facing) : self{
|
||||||
if(!in_array($facing, Facing::HORIZONTAL, true)){
|
$axis = Facing::axis($facing);
|
||||||
|
if($axis !== Axis::X && $axis !== Axis::Z){
|
||||||
throw new \InvalidArgumentException("Facing must be horizontal");
|
throw new \InvalidArgumentException("Facing must be horizontal");
|
||||||
}
|
}
|
||||||
$this->facing = $facing;
|
$this->facing = $facing;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user