mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 10:01:53 +00:00
Fix fence gates opening in opposite direction to expected
This still occasionally occurs due to a bug that seems to exist with entity rotation calculations. May happen at 45° 135° 225° and 315°
This commit is contained in:
parent
282095513a
commit
4ae18526d1
@ -81,13 +81,7 @@ class FenceGate extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
$faces = [
|
$this->meta = ($player instanceof Player ? ($player->getDirection() - 1) & 0x03 : 0);
|
||||||
0 => 3,
|
|
||||||
1 => 0,
|
|
||||||
2 => 1,
|
|
||||||
3 => 2,
|
|
||||||
];
|
|
||||||
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x03;
|
|
||||||
$this->getLevel()->setBlock($block, $this, true, true);
|
$this->getLevel()->setBlock($block, $this, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -100,8 +94,11 @@ class FenceGate extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function onActivate(Item $item, Player $player = null){
|
public function onActivate(Item $item, Player $player = null){
|
||||||
$this->meta ^= 0x04; //Flip open/close state
|
$this->meta = (($this->meta ^ 0x04) & ~0x02);
|
||||||
//TODO: Face player when opened
|
|
||||||
|
if($player !== null){
|
||||||
|
$this->meta |= (($player->getDirection() - 1) & 0x02);
|
||||||
|
}
|
||||||
|
|
||||||
$this->getLevel()->setBlock($this, $this, true);
|
$this->getLevel()->setBlock($this, $this, true);
|
||||||
$this->level->addSound(new DoorSound($this));
|
$this->level->addSound(new DoorSound($this));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user