Protocol changes for 1.2.0.25

This commit is contained in:
Dylan K. Taylor 2017-09-02 11:05:49 +01:00
parent 5d75d3d5b6
commit 604d8ecf9a
5 changed files with 17 additions and 8 deletions

View File

@ -2817,7 +2817,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->inventory->setHotbarSlotIndex($hotbarSlot, $slotLink === -1 ? $slotLink : $slotLink - 9); $this->inventory->setHotbarSlotIndex($hotbarSlot, $slotLink === -1 ? $slotLink : $slotLink - 9);
} }
$this->inventory->equipItem($packet->selectedSlot); $this->inventory->equipItem($packet->selectedHotbarSlot);
return true; return true;
} }

View File

@ -185,7 +185,7 @@ class PlayerInventory extends BaseInventory{
public function sendHotbar(){ public function sendHotbar(){
$pk = new PlayerHotbarPacket(); $pk = new PlayerHotbarPacket();
$pk->windowId = ContainerIds::INVENTORY; $pk->windowId = ContainerIds::INVENTORY;
$pk->selectedSlot = $this->getHeldItemIndex(); $pk->selectedHotbarSlot = $this->getHeldItemIndex();
$pk->slots = array_map(function(int $link){ return $link + $this->getHotbarSize(); }, $this->getHotbar()); $pk->slots = array_map(function(int $link){ return $link + $this->getHotbarSize(); }, $this->getHotbar());
$this->getHolder()->dataPacket($pk); $this->getHolder()->dataPacket($pk);
} }

View File

@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\DimensionIds;
use pocketmine\utils\Color; use pocketmine\utils\Color;
class ClientboundMapItemDataPacket extends DataPacket{ class ClientboundMapItemDataPacket extends DataPacket{
@ -40,6 +41,8 @@ class ClientboundMapItemDataPacket extends DataPacket{
public $mapId; public $mapId;
/** @var int */ /** @var int */
public $type; public $type;
/** @var int */
public $dimensionId = DimensionIds::OVERWORLD;
/** @var int[] */ /** @var int[] */
public $eids = []; public $eids = [];
@ -62,6 +65,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
protected function decodePayload(){ protected function decodePayload(){
$this->mapId = $this->getEntityUniqueId(); $this->mapId = $this->getEntityUniqueId();
$this->type = $this->getUnsignedVarInt(); $this->type = $this->getUnsignedVarInt();
$this->dimensionId = $this->getByte();
if(($this->type & 0x08) !== 0){ if(($this->type & 0x08) !== 0){
$count = $this->getUnsignedVarInt(); $count = $this->getUnsignedVarInt();
@ -117,6 +121,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
} }
$this->putUnsignedVarInt($type); $this->putUnsignedVarInt($type);
$this->putByte($this->dimensionId);
if(($type & 0x08) !== 0){ //TODO: find out what these are for if(($type & 0x08) !== 0){ //TODO: find out what these are for
$this->putUnsignedVarInt($eidsCount); $this->putUnsignedVarInt($eidsCount);

View File

@ -33,28 +33,32 @@ class PlayerHotbarPacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET; const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET;
/** @var int */ /** @var int */
public $selectedSlot; public $selectedHotbarSlot;
/** @var int */ /** @var int */
public $windowId = ContainerIds::INVENTORY; public $windowId = ContainerIds::INVENTORY;
/** @var int[] */ /** @var int[] */
public $slots = []; public $slots = [];
/** @var bool */
public $selectHotbarSlot = true;
protected function decodePayload(){ protected function decodePayload(){
$this->selectedSlot = $this->getUnsignedVarInt(); $this->selectedHotbarSlot = $this->getUnsignedVarInt();
$this->windowId = $this->getByte(); $this->windowId = $this->getByte();
$count = $this->getUnsignedVarInt(); $count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){ for($i = 0; $i < $count; ++$i){
$this->slots[$i] = Binary::signInt($this->getUnsignedVarInt()); $this->slots[$i] = Binary::signInt($this->getUnsignedVarInt());
} }
$this->selectHotbarSlot = $this->getBool();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putUnsignedVarInt($this->selectedSlot); $this->putUnsignedVarInt($this->selectedHotbarSlot);
$this->putByte($this->windowId); $this->putByte($this->windowId);
$this->putUnsignedVarInt(count($this->slots)); $this->putUnsignedVarInt(count($this->slots));
foreach($this->slots as $slot){ foreach($this->slots as $slot){
$this->putUnsignedVarInt($slot); $this->putUnsignedVarInt($slot);
} }
$this->putBool($this->selectHotbarSlot);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -39,15 +39,15 @@ interface ProtocolInfo{
/** /**
* Actual Minecraft: PE protocol version * Actual Minecraft: PE protocol version
*/ */
const CURRENT_PROTOCOL = 134; const CURRENT_PROTOCOL = 135;
/** /**
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. * Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
*/ */
const MINECRAFT_VERSION = 'v1.2.0.22 beta'; const MINECRAFT_VERSION = 'v1.2.0.25 beta';
/** /**
* Version number sent to clients in ping responses. * Version number sent to clients in ping responses.
*/ */
const MINECRAFT_VERSION_NETWORK = '1.2.0.22'; const MINECRAFT_VERSION_NETWORK = '1.2.0.25';
const LOGIN_PACKET = 0x01; const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02; const PLAY_STATUS_PACKET = 0x02;