mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
commit
2fb69cf607
1 changed files with 18 additions and 4 deletions
|
|
@ -31,9 +31,23 @@ class FenceGateBlock extends TransparentBlock{
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public function onActivate(Item $item, Player $player){
|
public function onActivate(Item $item, Player $player){
|
||||||
$this->meta ^= 0x04;
|
|
||||||
$this->level->setBlock($this, $this, true, false, true);
|
$meta = $this->meta;
|
||||||
$players = ServerAPI::request()->api->player->getAll($this->level);
|
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->fastSetBlockUpdate($this->x, $this->y, $this->z, $this->id, $meta);
|
||||||
|
$players = $this->level->players;
|
||||||
unset($players[$player->CID]);
|
unset($players[$player->CID]);
|
||||||
$pk = new LevelEventPacket;
|
$pk = new LevelEventPacket;
|
||||||
$pk->x = $this->x;
|
$pk->x = $this->x;
|
||||||
|
|
@ -43,5 +57,5 @@ class FenceGateBlock extends TransparentBlock{
|
||||||
$pk->data = 0;
|
$pk->data = 0;
|
||||||
ServerAPI::request()->api->player->broadcastPacket($players, $pk);
|
ServerAPI::request()->api->player->broadcastPacket($players, $pk);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue