diff --git a/composer.lock b/composer.lock index 1ea1b675c..4bfccbac9 100644 --- a/composer.lock +++ b/composer.lock @@ -187,12 +187,12 @@ "source": { "type": "git", "url": "https://github.com/pmmp/Math.git", - "reference": "6511fb0dcfeb60705d4169cc0422258b325af5c6" + "reference": "e5fd6cf9e71c285ff24bb3a3cbc22a15a8e73ac7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/Math/zipball/6511fb0dcfeb60705d4169cc0422258b325af5c6", - "reference": "6511fb0dcfeb60705d4169cc0422258b325af5c6", + "url": "https://api.github.com/repos/pmmp/Math/zipball/e5fd6cf9e71c285ff24bb3a3cbc22a15a8e73ac7", + "reference": "e5fd6cf9e71c285ff24bb3a3cbc22a15a8e73ac7", "shasum": "" }, "require": { @@ -218,7 +218,7 @@ "source": "https://github.com/pmmp/Math/tree/master", "issues": "https://github.com/pmmp/Math/issues" }, - "time": "2018-09-13T18:32:31+00:00" + "time": "2018-09-16T16:36:04+00:00" }, { "name": "pocketmine/nbt", diff --git a/src/pocketmine/block/Anvil.php b/src/pocketmine/block/Anvil.php index 7f8bf54fa..aa468082c 100644 --- a/src/pocketmine/block/Anvil.php +++ b/src/pocketmine/block/Anvil.php @@ -95,7 +95,7 @@ class Anvil extends Fallable{ } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ - $direction = $player !== null ? Bearing::rotate($player->getDirection(), -1) : 0; + $direction = $player !== null ? Bearing::rotate($player->getDirection(), 1) : 0; $this->meta = $this->getVariant() | $direction; return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/pocketmine/block/Bed.php b/src/pocketmine/block/Bed.php index f6ee877c5..d8961d94a 100644 --- a/src/pocketmine/block/Bed.php +++ b/src/pocketmine/block/Bed.php @@ -152,7 +152,7 @@ class Bed extends Transparent{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); if(!$down->isTransparent()){ - $this->meta = $player instanceof Player ? Bearing::opposite($player->getDirection()) : 0; //rotate 180 degrees + $this->meta = $player instanceof Player ? $player->getDirection() : 0; $next = $this->getSide(self::getOtherHalfSide($this->meta)); if($next->canBeReplaced() and !$next->getSide(Facing::DOWN)->isTransparent()){ parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 3cc32970f..2371b1ad2 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -63,7 +63,7 @@ class BurningFurnace extends Solid{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($player !== null){ - $this->meta = Bearing::toFacing($player->getDirection()); + $this->meta = Bearing::toFacing(Bearing::opposite($player->getDirection())); } if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){ Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this, $face, $item, $player)); diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index 942503bfc..ddec85663 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -60,7 +60,7 @@ class Chest extends Transparent{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ $chest = null; if($player !== null){ - $this->meta = Bearing::toFacing($player->getDirection()); + $this->meta = Bearing::toFacing(Bearing::opposite($player->getDirection())); } foreach([ diff --git a/src/pocketmine/block/Door.php b/src/pocketmine/block/Door.php index be43b8ae4..a0371f49e 100644 --- a/src/pocketmine/block/Door.php +++ b/src/pocketmine/block/Door.php @@ -127,17 +127,19 @@ abstract class Door extends Transparent{ return false; } - $ccw = Bearing::toFacing($player instanceof Player ? Bearing::rotate($player->getDirection(), -1) : Bearing::EAST); + //door faces this way when opened (unless it's right, in which case it's the opposite) + $direction = $player !== null ? Bearing::rotate($player->getDirection(), 1) : Bearing::NORTH; - $next = $this->getSide(Facing::opposite($ccw)); - $next2 = $this->getSide($ccw); + $facing = Bearing::toFacing($direction); + $next = $this->getSide(Facing::opposite($facing)); + $next2 = $this->getSide($facing); $metaUp = 0x08; if($next->getId() === $this->getId() or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge $metaUp |= 0x01; } - $this->setDamage(Bearing::rotate($player->getDirection(), -1)); + $this->setDamage($direction); parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); $this->getLevel()->setBlock($blockUp, BlockFactory::get($this->getId(), $metaUp), true); //Top return true; diff --git a/src/pocketmine/block/EnderChest.php b/src/pocketmine/block/EnderChest.php index c619a3fef..348c5c701 100644 --- a/src/pocketmine/block/EnderChest.php +++ b/src/pocketmine/block/EnderChest.php @@ -63,7 +63,7 @@ class EnderChest extends Chest{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($player !== null){ - $this->meta = Bearing::toFacing($player->getDirection()); + $this->meta = Bearing::toFacing(Bearing::opposite($player->getDirection())); } if(Block::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){ diff --git a/src/pocketmine/block/FenceGate.php b/src/pocketmine/block/FenceGate.php index 69fda8814..e3e3191b9 100644 --- a/src/pocketmine/block/FenceGate.php +++ b/src/pocketmine/block/FenceGate.php @@ -26,7 +26,6 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\level\sound\DoorSound; use pocketmine\math\AxisAlignedBB; -use pocketmine\math\Bearing; use pocketmine\math\Vector3; use pocketmine\Player; @@ -70,7 +69,7 @@ class FenceGate extends Transparent{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($player !== null){ - $this->meta = Bearing::opposite($player->getDirection()); + $this->meta = $player->getDirection(); } return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); @@ -84,7 +83,7 @@ class FenceGate extends Transparent{ $this->meta = (($this->meta ^ 0x04) & ~0x02); if($player !== null){ - $this->meta |= (Bearing::opposite($player->getDirection()) & 0x02); //open towards the player, retaining axis + $this->meta |= ($player->getDirection() & 0x02); //open towards the player, retaining axis } $this->getLevel()->setBlock($this, $this, true); diff --git a/src/pocketmine/block/GlazedTerracotta.php b/src/pocketmine/block/GlazedTerracotta.php index d8276666b..803527475 100644 --- a/src/pocketmine/block/GlazedTerracotta.php +++ b/src/pocketmine/block/GlazedTerracotta.php @@ -46,7 +46,7 @@ class GlazedTerracotta extends Solid{ public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ if($player !== null){ - $this->meta = Bearing::toFacing($player->getDirection()); + $this->meta = Bearing::toFacing(Bearing::opposite($player->getDirection())); } return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player); diff --git a/src/pocketmine/block/Stair.php b/src/pocketmine/block/Stair.php index db0bcdaa4..1026b2fd3 100644 --- a/src/pocketmine/block/Stair.php +++ b/src/pocketmine/block/Stair.php @@ -71,14 +71,8 @@ abstract class Stair extends Transparent{ } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ - static $faces = [ - Bearing::SOUTH => 3, //north - Bearing::WEST => 0, //east - Bearing::NORTH => 2, //south - Bearing::EAST => 1 //west - ]; if($player !== null){ - $this->meta = $faces[$player->getDirection()]; + $this->meta = 5 - Bearing::toFacing($player->getDirection()); } if(($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN){ $this->meta |= 0x04; //Upside-down stairs diff --git a/src/pocketmine/block/Trapdoor.php b/src/pocketmine/block/Trapdoor.php index b5eb3d9d8..0b5278582 100644 --- a/src/pocketmine/block/Trapdoor.php +++ b/src/pocketmine/block/Trapdoor.php @@ -83,14 +83,9 @@ class Trapdoor extends Transparent{ } public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{ - static $directions = [ - Bearing::SOUTH => 2, - Bearing::WEST => 1, - Bearing::NORTH => 3, - Bearing::EAST => 0 - ]; if($player !== null){ - $this->meta = $directions[$player->getDirection()]; + //TODO: in PC the values are reversed (3 - (5 - facing)) + $this->meta = 5 - Bearing::toFacing(Bearing::opposite($player->getDirection())); } if(($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN){ $this->meta |= self::MASK_UPPER; //top half of block