mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-28 22:30:01 +00:00
Make use of Bearing::opposite()
This commit is contained in:
parent
f488e594f6
commit
2b8405e6ee
@ -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::rotate($player->getDirection(), 2) : 0; //rotate 180 degrees
|
$this->meta = $player instanceof Player ? Bearing::opposite($player->getDirection()) : 0; //rotate 180 degrees
|
||||||
$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);
|
||||||
|
@ -70,7 +70,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::rotate($player->getDirection(), 2);
|
$this->meta = Bearing::opposite($player->getDirection());
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
|
||||||
@ -84,7 +84,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::rotate($player->getDirection(), 2) & 0x02); //open towards the player, retaining axis
|
$this->meta |= (Bearing::opposite($player->getDirection()) & 0x02); //open towards the player, retaining axis
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getLevel()->setBlock($this, $this, true);
|
$this->getLevel()->setBlock($this, $this, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user