Protocol changes for 1.2.10

This commit is contained in:
Dylan K. Taylor
2018-01-25 14:42:27 +00:00
parent a3fa8adf4a
commit fc795b80ae
12 changed files with 118 additions and 30 deletions

View File

@ -31,6 +31,9 @@ use pocketmine\network\mcpe\protocol\types\ContainerIds;
use pocketmine\utils\Binary;
#endif
/**
* One of the most useless packets.
*/
class PlayerHotbarPacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET;
@ -38,28 +41,18 @@ class PlayerHotbarPacket extends DataPacket{
public $selectedHotbarSlot;
/** @var int */
public $windowId = ContainerIds::INVENTORY;
/** @var int[] */
public $slots = [];
/** @var bool */
public $selectHotbarSlot = true;
protected function decodePayload(){
$this->selectedHotbarSlot = $this->getUnsignedVarInt();
$this->windowId = $this->getByte();
$count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){
$this->slots[$i] = Binary::signInt($this->getUnsignedVarInt());
}
$this->selectHotbarSlot = $this->getBool();
}
protected function encodePayload(){
$this->putUnsignedVarInt($this->selectedHotbarSlot);
$this->putByte($this->windowId);
$this->putUnsignedVarInt(count($this->slots));
foreach($this->slots as $slot){
$this->putUnsignedVarInt($slot);
}
$this->putBool($this->selectHotbarSlot);
}