mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
Protocol changes for 1.2.0.25
This commit is contained in:
parent
5d75d3d5b6
commit
604d8ecf9a
@ -2817,7 +2817,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->inventory->setHotbarSlotIndex($hotbarSlot, $slotLink === -1 ? $slotLink : $slotLink - 9);
|
||||
}
|
||||
|
||||
$this->inventory->equipItem($packet->selectedSlot);
|
||||
$this->inventory->equipItem($packet->selectedHotbarSlot);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ class PlayerInventory extends BaseInventory{
|
||||
public function sendHotbar(){
|
||||
$pk = new PlayerHotbarPacket();
|
||||
$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());
|
||||
$this->getHolder()->dataPacket($pk);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
use pocketmine\network\mcpe\protocol\types\DimensionIds;
|
||||
use pocketmine\utils\Color;
|
||||
|
||||
class ClientboundMapItemDataPacket extends DataPacket{
|
||||
@ -40,6 +41,8 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
public $mapId;
|
||||
/** @var int */
|
||||
public $type;
|
||||
/** @var int */
|
||||
public $dimensionId = DimensionIds::OVERWORLD;
|
||||
|
||||
/** @var int[] */
|
||||
public $eids = [];
|
||||
@ -62,6 +65,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
protected function decodePayload(){
|
||||
$this->mapId = $this->getEntityUniqueId();
|
||||
$this->type = $this->getUnsignedVarInt();
|
||||
$this->dimensionId = $this->getByte();
|
||||
|
||||
if(($this->type & 0x08) !== 0){
|
||||
$count = $this->getUnsignedVarInt();
|
||||
@ -117,6 +121,7 @@ class ClientboundMapItemDataPacket extends DataPacket{
|
||||
}
|
||||
|
||||
$this->putUnsignedVarInt($type);
|
||||
$this->putByte($this->dimensionId);
|
||||
|
||||
if(($type & 0x08) !== 0){ //TODO: find out what these are for
|
||||
$this->putUnsignedVarInt($eidsCount);
|
||||
|
@ -33,28 +33,32 @@ class PlayerHotbarPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::PLAYER_HOTBAR_PACKET;
|
||||
|
||||
/** @var int */
|
||||
public $selectedSlot;
|
||||
public $selectedHotbarSlot;
|
||||
/** @var int */
|
||||
public $windowId = ContainerIds::INVENTORY;
|
||||
/** @var int[] */
|
||||
public $slots = [];
|
||||
/** @var bool */
|
||||
public $selectHotbarSlot = true;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->selectedSlot = $this->getUnsignedVarInt();
|
||||
$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->selectedSlot);
|
||||
$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);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
|
@ -39,15 +39,15 @@ interface ProtocolInfo{
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const MINECRAFT_VERSION = 'v1.2.0.22 beta';
|
||||
const MINECRAFT_VERSION = 'v1.2.0.25 beta';
|
||||
/**
|
||||
* 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 PLAY_STATUS_PACKET = 0x02;
|
||||
|
Loading…
x
Reference in New Issue
Block a user