mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-14 23:45:34 +00:00
Make use of Facing::rotateY() to reduce boilerplate
This commit is contained in:
parent
1cac2b098e
commit
8dbeda69a7
18
composer.lock
generated
18
composer.lock
generated
@ -117,16 +117,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mdanter/ecc",
|
"name": "mdanter/ecc",
|
||||||
"version": "v0.5.1",
|
"version": "v0.5.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpecc/phpecc.git",
|
"url": "https://github.com/phpecc/phpecc.git",
|
||||||
"reference": "9a3aca17c6dfc04bdaad2e7ddab3b8df656ffc5b"
|
"reference": "b95f25cc1bacc83a9f0ccd375900b7cfd343029e"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpecc/phpecc/zipball/9a3aca17c6dfc04bdaad2e7ddab3b8df656ffc5b",
|
"url": "https://api.github.com/repos/phpecc/phpecc/zipball/b95f25cc1bacc83a9f0ccd375900b7cfd343029e",
|
||||||
"reference": "9a3aca17c6dfc04bdaad2e7ddab3b8df656ffc5b",
|
"reference": "b95f25cc1bacc83a9f0ccd375900b7cfd343029e",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -185,7 +185,7 @@
|
|||||||
"secp256k1",
|
"secp256k1",
|
||||||
"secp256r1"
|
"secp256r1"
|
||||||
],
|
],
|
||||||
"time": "2018-12-01T23:35:23+00:00"
|
"time": "2018-12-03T18:17:01+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/binaryutils",
|
"name": "pocketmine/binaryutils",
|
||||||
@ -227,12 +227,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pmmp/Math.git",
|
"url": "https://github.com/pmmp/Math.git",
|
||||||
"reference": "5bb6facf8c46212bdb78d6bb1be6fbd2891b200d"
|
"reference": "a162c02be87fd49abd195a7330e61be9d4b8e766"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/5bb6facf8c46212bdb78d6bb1be6fbd2891b200d",
|
"url": "https://api.github.com/repos/pmmp/Math/zipball/a162c02be87fd49abd195a7330e61be9d4b8e766",
|
||||||
"reference": "5bb6facf8c46212bdb78d6bb1be6fbd2891b200d",
|
"reference": "a162c02be87fd49abd195a7330e61be9d4b8e766",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -258,7 +258,7 @@
|
|||||||
"source": "https://github.com/pmmp/Math/tree/master",
|
"source": "https://github.com/pmmp/Math/tree/master",
|
||||||
"issues": "https://github.com/pmmp/Math/issues"
|
"issues": "https://github.com/pmmp/Math/issues"
|
||||||
},
|
},
|
||||||
"time": "2018-12-02T11:40:31+00:00"
|
"time": "2018-12-07T10:47:16+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/nbt",
|
"name": "pocketmine/nbt",
|
||||||
|
@ -74,7 +74,7 @@ class Anvil extends Fallable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function recalculateBoundingBox() : ?AxisAlignedBB{
|
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{
|
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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($player !== null){
|
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);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ class Chest extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach([
|
foreach([
|
||||||
Facing::rotate($player->getHorizontalFacing(), Facing::AXIS_Y, false),
|
Facing::rotateY($player->getHorizontalFacing(), false),
|
||||||
Facing::rotate($player->getHorizontalFacing(), Facing::AXIS_Y, true)
|
Facing::rotateY($player->getHorizontalFacing(), true)
|
||||||
] as $side){
|
] as $side){
|
||||||
$c = $this->getSide($side);
|
$c = $this->getSide($side);
|
||||||
if($c instanceof Chest and $c->isSameType($this) and $c->facing === $this->facing){
|
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{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return AxisAlignedBB::one()
|
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::DOWN, (7 - $this->age * 2) / 16)
|
||||||
->trim(Facing::UP, 0.25)
|
->trim(Facing::UP, 0.25)
|
||||||
->trim(Facing::opposite($this->facing), 1 / 16) //gap between log and pod
|
->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{
|
protected function recalculateBoundingBox() : ?AxisAlignedBB{
|
||||||
return AxisAlignedBB::one()
|
return AxisAlignedBB::one()
|
||||||
->extend(Facing::UP, 1)
|
->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{
|
public function onNearbyBlockChange() : void{
|
||||||
@ -113,8 +113,8 @@ abstract class Door extends Transparent{
|
|||||||
$this->facing = $player->getHorizontalFacing();
|
$this->facing = $player->getHorizontalFacing();
|
||||||
}
|
}
|
||||||
|
|
||||||
$next = $this->getSide(Facing::rotate($this->facing, Facing::AXIS_Y, false));
|
$next = $this->getSide(Facing::rotateY($this->facing, false));
|
||||||
$next2 = $this->getSide(Facing::rotate($this->facing, Facing::AXIS_Y, true));
|
$next2 = $this->getSide(Facing::rotateY($this->facing, true));
|
||||||
|
|
||||||
if($next->isSameType($this) or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
|
if($next->isSameType($this) or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
|
||||||
$this->hingeRight = true;
|
$this->hingeRight = true;
|
||||||
|
@ -59,7 +59,7 @@ abstract class Stair extends Transparent{
|
|||||||
public function readStateFromWorld() : void{
|
public function readStateFromWorld() : void{
|
||||||
parent::readStateFromWorld();
|
parent::readStateFromWorld();
|
||||||
|
|
||||||
$clockwise = Facing::rotate($this->facing, Facing::AXIS_Y, true);
|
$clockwise = Facing::rotateY($this->facing, true);
|
||||||
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
|
if(($backFacing = $this->getPossibleCornerFacing(false)) !== null){
|
||||||
$this->shape = $backFacing === $clockwise ? self::SHAPE_OUTER_RIGHT : self::SHAPE_OUTER_LEFT;
|
$this->shape = $backFacing === $clockwise ? self::SHAPE_OUTER_RIGHT : self::SHAPE_OUTER_LEFT;
|
||||||
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
|
}elseif(($frontFacing = $this->getPossibleCornerFacing(true)) !== null){
|
||||||
@ -82,13 +82,13 @@ abstract class Stair extends Transparent{
|
|||||||
$topStep->trim(Facing::opposite($this->facing), 0.5);
|
$topStep->trim(Facing::opposite($this->facing), 0.5);
|
||||||
|
|
||||||
if($this->shape === self::SHAPE_OUTER_LEFT or $this->shape === self::SHAPE_OUTER_RIGHT){
|
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){
|
}elseif($this->shape === self::SHAPE_INNER_LEFT or $this->shape === self::SHAPE_INNER_RIGHT){
|
||||||
//add an extra cube
|
//add an extra cube
|
||||||
$extraCube = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
|
$extraCube = new AxisAlignedBB(0, $minY, 0, 1, $minY + 0.5, 1);
|
||||||
$bbs[] = $extraCube
|
$bbs[] = $extraCube
|
||||||
->trim($this->facing, 0.5) //avoid overlapping with main step
|
->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;
|
$bbs[] = $topStep;
|
||||||
|
@ -240,7 +240,7 @@ class Painting extends Entity{
|
|||||||
$horizontalStart = (int) (ceil($width / 2) - 1);
|
$horizontalStart = (int) (ceil($width / 2) - 1);
|
||||||
$verticalStart = (int) (ceil($height / 2) - 1);
|
$verticalStart = (int) (ceil($height / 2) - 1);
|
||||||
|
|
||||||
$rotatedFace = Facing::rotate($facing, Facing::AXIS_Y, false);
|
$rotatedFace = Facing::rotateY($facing, false);
|
||||||
|
|
||||||
$oppositeSide = Facing::opposite($facing);
|
$oppositeSide = Facing::opposite($facing);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user