public function onBreak(Item $item)
{
$sides = [0 => 3, 1 => 4, 2 => 2, 3 => 5, 8 => 2, 9 => 5, 10 => 3, 11 => 4];
if (($this->meta & 0x8) === 0x8) {
//This is the Top part of bed
$next = $this->getSide($sides[$this->meta]);
if ($next->getId() === $this->id and ($next->meta | 0x8) === $this->meta) {
//Checks if the block ID and meta are right
$this->getLevel()->setBlock($next, new Air(), true, true);
}
} else {
//Bottom Part of Bed
$next = $this->getSide($sides[$this->meta]);
if ($next->getId() === $this->id and $next->meta === ($this->meta | 0x8)) {
$this->getLevel()->setBlock($next, new Air(), true, true);
}
}
$this->getLevel()->setBlock($this, new Air(), true, true);
return true;
}