Added new window types and found some UpdateTradePacket fields

This commit is contained in:
Dylan K. Taylor 2017-03-13 11:27:44 +00:00
parent e7dbda922a
commit 9e341f74d8
2 changed files with 12 additions and 6 deletions

View File

@ -26,13 +26,14 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\InventoryNetworkIds;
class UpdateTradePacket extends DataPacket{ class UpdateTradePacket extends DataPacket{
const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET; const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET;
//TODO: find fields //TODO: find fields
public $byte1; public $windowId;
public $byte2; public $windowType = InventoryNetworkIds::TRADING; //Mojang hardcoded this -_-
public $varint1; public $varint1;
public $varint2; public $varint2;
public $isWilling; public $isWilling;
@ -42,8 +43,8 @@ class UpdateTradePacket extends DataPacket{
public $offers; public $offers;
public function decode(){ public function decode(){
$this->byte1 = $this->getByte(); $this->windowId = $this->getByte();
$this->byte2 = $this->getByte(); $this->windowType = $this->getByte();
$this->varint1 = $this->getVarInt(); $this->varint1 = $this->getVarInt();
$this->varint2 = $this->getVarInt(); $this->varint2 = $this->getVarInt();
$this->isWilling = $this->getBool(); $this->isWilling = $this->getBool();
@ -55,8 +56,8 @@ class UpdateTradePacket extends DataPacket{
public function encode(){ public function encode(){
$this->reset(); $this->reset();
$this->putByte($this->byte1); $this->putByte($this->windowId);
$this->putByte($this->byte2); $this->putByte($this->windowType);
$this->putVarInt($this->varint1); $this->putVarInt($this->varint1);
$this->putVarInt($this->varint2); $this->putVarInt($this->varint2);
$this->putBool($this->isWilling); $this->putBool($this->isWilling);

View File

@ -39,4 +39,9 @@ interface InventoryNetworkIds{
const MINECART_CHEST = 10; const MINECART_CHEST = 10;
const MINECART_HOPPER = 11; const MINECART_HOPPER = 11;
const HORSE = 12; const HORSE = 12;
const BEACON = 13;
const STRUCTURE_EDITOR = 14;
const TRADING = 15;
const COMMAND_BLOCK = 16;
} }