mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-31 23:33:06 +00:00
Fixed mess of rotations being inverted
This commit is contained in:
parent
f7f06c993d
commit
1bb4daa7d1
8
composer.lock
generated
8
composer.lock
generated
@ -187,12 +187,12 @@
|
|||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/pmmp/Math.git",
|
"url": "https://github.com/pmmp/Math.git",
|
||||||
"reference": "6511fb0dcfeb60705d4169cc0422258b325af5c6"
|
"reference": "e5fd6cf9e71c285ff24bb3a3cbc22a15a8e73ac7"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/pmmp/Math/zipball/6511fb0dcfeb60705d4169cc0422258b325af5c6",
|
"url": "https://api.github.com/repos/pmmp/Math/zipball/e5fd6cf9e71c285ff24bb3a3cbc22a15a8e73ac7",
|
||||||
"reference": "6511fb0dcfeb60705d4169cc0422258b325af5c6",
|
"reference": "e5fd6cf9e71c285ff24bb3a3cbc22a15a8e73ac7",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -218,7 +218,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-09-13T18:32:31+00:00"
|
"time": "2018-09-16T16:36:04+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "pocketmine/nbt",
|
"name": "pocketmine/nbt",
|
||||||
|
@ -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{
|
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;
|
$this->meta = $this->getVariant() | $direction;
|
||||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
}
|
}
|
||||||
|
@ -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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
$down = $this->getSide(Facing::DOWN);
|
$down = $this->getSide(Facing::DOWN);
|
||||||
if(!$down->isTransparent()){
|
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));
|
$next = $this->getSide(self::getOtherHalfSide($this->meta));
|
||||||
if($next->canBeReplaced() and !$next->getSide(Facing::DOWN)->isTransparent()){
|
if($next->canBeReplaced() and !$next->getSide(Facing::DOWN)->isTransparent()){
|
||||||
parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
|
@ -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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($player !== null){
|
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)){
|
if(parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||||
Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this, $face, $item, $player));
|
Tile::createTile(Tile::FURNACE, $this->getLevel(), TileFurnace::createNBT($this, $face, $item, $player));
|
||||||
|
@ -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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
$chest = null;
|
$chest = null;
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
$this->meta = Bearing::toFacing($player->getDirection());
|
$this->meta = Bearing::toFacing(Bearing::opposite($player->getDirection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach([
|
foreach([
|
||||||
|
@ -127,17 +127,19 @@ abstract class Door extends Transparent{
|
|||||||
return false;
|
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));
|
$facing = Bearing::toFacing($direction);
|
||||||
$next2 = $this->getSide($ccw);
|
$next = $this->getSide(Facing::opposite($facing));
|
||||||
|
$next2 = $this->getSide($facing);
|
||||||
|
|
||||||
$metaUp = 0x08;
|
$metaUp = 0x08;
|
||||||
if($next->getId() === $this->getId() or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
|
if($next->getId() === $this->getId() or (!$next2->isTransparent() and $next->isTransparent())){ //Door hinge
|
||||||
$metaUp |= 0x01;
|
$metaUp |= 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setDamage(Bearing::rotate($player->getDirection(), -1));
|
$this->setDamage($direction);
|
||||||
parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
$this->getLevel()->setBlock($blockUp, BlockFactory::get($this->getId(), $metaUp), true); //Top
|
$this->getLevel()->setBlock($blockUp, BlockFactory::get($this->getId(), $metaUp), true); //Top
|
||||||
return true;
|
return true;
|
||||||
|
@ -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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($player !== null){
|
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)){
|
if(Block::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player)){
|
||||||
|
@ -26,7 +26,6 @@ namespace pocketmine\block;
|
|||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\level\sound\DoorSound;
|
use pocketmine\level\sound\DoorSound;
|
||||||
use pocketmine\math\AxisAlignedBB;
|
use pocketmine\math\AxisAlignedBB;
|
||||||
use pocketmine\math\Bearing;
|
|
||||||
use pocketmine\math\Vector3;
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\Player;
|
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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
$this->meta = Bearing::opposite($player->getDirection());
|
$this->meta = $player->getDirection();
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
@ -84,7 +83,7 @@ class FenceGate extends Transparent{
|
|||||||
$this->meta = (($this->meta ^ 0x04) & ~0x02);
|
$this->meta = (($this->meta ^ 0x04) & ~0x02);
|
||||||
|
|
||||||
if($player !== null){
|
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);
|
$this->getLevel()->setBlock($this, $this, true);
|
||||||
|
@ -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{
|
public function place(Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, Player $player = null) : bool{
|
||||||
if($player !== null){
|
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);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
|
@ -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{
|
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){
|
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){
|
if(($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN){
|
||||||
$this->meta |= 0x04; //Upside-down stairs
|
$this->meta |= 0x04; //Upside-down stairs
|
||||||
|
@ -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{
|
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){
|
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){
|
if(($clickVector->y > 0.5 and $face !== Facing::UP) or $face === Facing::DOWN){
|
||||||
$this->meta |= self::MASK_UPPER; //top half of block
|
$this->meta |= self::MASK_UPPER; //top half of block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user