Entity: add getHorizontalFacing(), clean up some boilerplate code

This commit is contained in:
Dylan K. Taylor
2018-12-05 20:27:43 +00:00
parent f60d13548e
commit 39e383a175
14 changed files with 20 additions and 23 deletions

View File

@ -69,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->facing = Bearing::toFacing($player->getDirection());
$this->facing = $player->getHorizontalFacing();
}
return parent::place($item, $blockReplace, $blockClicked, $face, $clickVector, $player);
@ -78,7 +78,7 @@ class FenceGate extends Transparent{
public function onActivate(Item $item, Player $player = null) : bool{
$this->open = !$this->open;
if($this->open and $player !== null){
$playerFacing = Bearing::toFacing($player->getDirection());
$playerFacing = $player->getHorizontalFacing();
if($playerFacing === Facing::opposite($this->facing)){
$this->facing = $playerFacing;
}