mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
ported from vanilla
This commit is contained in:
parent
af9943a6e5
commit
46326707d0
1 changed files with 16 additions and 14 deletions
|
|
@ -31,21 +31,23 @@ class FenceGateBlock extends TransparentBlock{
|
|||
);
|
||||
}
|
||||
public function onActivate(Item $item, Player $player){
|
||||
$faces = array(
|
||||
0 => 2,
|
||||
1 => 3,
|
||||
2 => 0,
|
||||
3 => 1,
|
||||
);
|
||||
$playerDirection = $faces[$player->entity->getDirection()] & 0x03;
|
||||
$gateDirection = $this->meta & 0x03;
|
||||
if ($playerDirection === $gateDirection) {
|
||||
$this->meta ^= 0x04;
|
||||
} else if (($playerDirection + 2) % 4 === $gateDirection) {
|
||||
$this->meta = ($this->meta & 0x04) | $playerDirection;
|
||||
|
||||
$meta = $this->meta;
|
||||
if(($meta & 4) != 0){
|
||||
$meta ^= 4;
|
||||
}else{
|
||||
$direction = ($player->entity->yaw * 4 / 360) + 0.5;
|
||||
$blockDirection = (int)$direction;
|
||||
if($direction < $blockDirection) --$blockDirection;
|
||||
$blockDirection &= 3;
|
||||
if(($meta & 3) == (($blockDirection + 2) & 3)){
|
||||
$meta = $blockDirection;
|
||||
}
|
||||
$meta |= 4;
|
||||
}
|
||||
$this->level->setBlock($this, $this, true, false, true);
|
||||
$players = ServerAPI::request()->api->player->getAll($this->level);
|
||||
|
||||
$this->level->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->id, $meta);
|
||||
$players = $this->level->players;
|
||||
unset($players[$player->CID]);
|
||||
$pk = new LevelEventPacket;
|
||||
$pk->x = $this->x;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue