public function encode()
{
$this->reset();
$this->putByte($this->windowid);
$this->putShort(count($this->slots));
foreach ($this->slots as $slot) {
$this->putSlot($slot);
}
if ($this->windowid === self::SPECIAL_INVENTORY and count($this->hotbar) > 0) {
$this->putShort(count($this->hotbar));
foreach ($this->hotbar as $slot) {
$this->putInt($slot);
}
} else {
$this->putShort(0);
}
}