Make use of Bearing::opposite()

This commit is contained in:
Dylan K. Taylor 2018-09-13 19:35:47 +01:00
parent f488e594f6
commit 2b8405e6ee
2 changed files with 3 additions and 3 deletions

View File

@ -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);

View File

@ -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);