public function onActivate(Item $item, Player $player = null)
{
if (($this->getDamage() & 0x8) === 0x8) {
//Top
$down = $this->getSide(Vector3::SIDE_DOWN);
if ($down->getId() === $this->getId()) {
$meta = $down->getDamage() ^ 0x4;
$this->getLevel()->setBlock($down, Block::get($this->getId(), $meta), true);
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
if ($player instanceof Player) {
unset($players[$player->getLoaderId()]);
}
$this->level->addSound(new DoorSound($this));
return true;
}
return false;
} else {
$this->meta ^= 0x4;
$this->getLevel()->setBlock($this, $this, true);
$players = $this->getLevel()->getChunkPlayers($this->x >> 4, $this->z >> 4);
if ($player instanceof Player) {
unset($players[$player->getLoaderId()]);
}
$this->level->addSound(new DoorSound($this));
}
return true;
}