Updated for 1.2.0.22

This commit is contained in:
Dylan K. Taylor 2017-08-22 11:35:56 +01:00
parent 121777375e
commit 4250e99e3a
5 changed files with 39 additions and 27 deletions

View File

@ -3403,11 +3403,18 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
$this->dataPacket($pk); $this->dataPacket($pk);
} }
/**
* Sends a popup message to the player
*
* TODO: add translation type popups
*
* @param string $message
* @param string $subtitle @deprecated
*/
public function sendPopup(string $message, string $subtitle = ""){ public function sendPopup(string $message, string $subtitle = ""){
$pk = new TextPacket(); $pk = new TextPacket();
$pk->type = TextPacket::TYPE_POPUP; $pk->type = TextPacket::TYPE_POPUP;
$pk->source = $message; $pk->message = $message;
$pk->message = $subtitle;
$this->dataPacket($pk); $this->dataPacket($pk);
} }

View File

@ -36,21 +36,22 @@ class PlayerActionPacket extends DataPacket{
const ACTION_STOP_BREAK = 2; const ACTION_STOP_BREAK = 2;
const ACTION_GET_UPDATED_BLOCK = 3; const ACTION_GET_UPDATED_BLOCK = 3;
const ACTION_DROP_ITEM = 4; const ACTION_DROP_ITEM = 4;
const ACTION_STOP_SLEEPING = 5; const ACTION_START_SLEEPING = 5;
const ACTION_RESPAWN = 6; const ACTION_STOP_SLEEPING = 6;
const ACTION_JUMP = 7; const ACTION_RESPAWN = 7;
const ACTION_START_SPRINT = 8; const ACTION_JUMP = 8;
const ACTION_STOP_SPRINT = 9; const ACTION_START_SPRINT = 9;
const ACTION_START_SNEAK = 10; const ACTION_STOP_SPRINT = 10;
const ACTION_STOP_SNEAK = 11; const ACTION_START_SNEAK = 11;
const ACTION_DIMENSION_CHANGE_REQUEST = 12; //sent when dying in different dimension const ACTION_STOP_SNEAK = 12;
const ACTION_DIMENSION_CHANGE_ACK = 13; //sent when spawning in a different dimension to tell the server we spawned const ACTION_DIMENSION_CHANGE_REQUEST = 13; //sent when dying in different dimension
const ACTION_START_GLIDE = 14; const ACTION_DIMENSION_CHANGE_ACK = 14; //sent when spawning in a different dimension to tell the server we spawned
const ACTION_STOP_GLIDE = 15; const ACTION_START_GLIDE = 15;
const ACTION_BUILD_DENIED = 16; const ACTION_STOP_GLIDE = 16;
const ACTION_CONTINUE_BREAK = 17; const ACTION_BUILD_DENIED = 17;
const ACTION_CONTINUE_BREAK = 18;
const ACTION_SET_ENCHANTMENT_SEED = 19; const ACTION_SET_ENCHANTMENT_SEED = 20;
/** @var int */ /** @var int */
public $entityRuntimeId; public $entityRuntimeId;

View File

@ -39,15 +39,15 @@ interface ProtocolInfo{
/** /**
* Actual Minecraft: PE protocol version * Actual Minecraft: PE protocol version
*/ */
const CURRENT_PROTOCOL = 133; const CURRENT_PROTOCOL = 134;
/** /**
* 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.18 beta'; const MINECRAFT_VERSION = 'v1.2.0.22 beta';
/** /**
* Version number sent to clients in ping responses. * Version number sent to clients in ping responses.
*/ */
const MINECRAFT_VERSION_NETWORK = '1.2.0.18'; const MINECRAFT_VERSION_NETWORK = '1.2.0.22';
const LOGIN_PACKET = 0x01; const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02; const PLAY_STATUS_PACKET = 0x02;

View File

@ -34,19 +34,15 @@ class ShowStoreOfferPacket extends DataPacket{
public $offerId; public $offerId;
/** @var bool */ /** @var bool */
public $unknownBool; public $unknownBool;
/** @var string */
public $unknownString;
protected function decodePayload(){ protected function decodePayload(){
$this->offerId = $this->getString(); $this->offerId = $this->getString();
$this->unknownBool = $this->getBool(); $this->unknownBool = $this->getBool();
$this->unknownString = $this->getString();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putString($this->offerId); $this->putString($this->offerId);
$this->putBool($this->unknownBool); $this->putBool($this->unknownBool);
$this->putString($this->unknownString);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{

View File

@ -51,12 +51,13 @@ class TextPacket extends DataPacket{
public $message; public $message;
/** @var string[] */ /** @var string[] */
public $parameters = []; public $parameters = [];
/** @var string */
public $xboxUserId = "";
protected function decodePayload(){ protected function decodePayload(){
$this->type = $this->getByte(); $this->type = $this->getByte();
$this->needsTranslation = $this->getBool(); $this->needsTranslation = $this->getBool();
switch($this->type){ switch($this->type){
case self::TYPE_POPUP:
case self::TYPE_CHAT: case self::TYPE_CHAT:
case self::TYPE_WHISPER: case self::TYPE_WHISPER:
/** @noinspection PhpMissingBreakStatementInspection */ /** @noinspection PhpMissingBreakStatementInspection */
@ -68,21 +69,24 @@ class TextPacket extends DataPacket{
$this->message = $this->getString(); $this->message = $this->getString();
break; break;
case self::TYPE_JUKEBOX_POPUP:
case self::TYPE_TRANSLATION: case self::TYPE_TRANSLATION:
case self::TYPE_POPUP:
case self::TYPE_JUKEBOX_POPUP:
$this->message = $this->getString(); $this->message = $this->getString();
$count = $this->getUnsignedVarInt(); $count = $this->getUnsignedVarInt();
for($i = 0; $i < $count; ++$i){ for($i = 0; $i < $count; ++$i){
$this->parameters[] = $this->getString(); $this->parameters[] = $this->getString();
} }
break;
} }
$this->xboxUserId = $this->getString();
} }
protected function encodePayload(){ protected function encodePayload(){
$this->putByte($this->type); $this->putByte($this->type);
$this->putBool($this->needsTranslation); $this->putBool($this->needsTranslation);
switch($this->type){ switch($this->type){
case self::TYPE_POPUP:
case self::TYPE_CHAT: case self::TYPE_CHAT:
case self::TYPE_WHISPER: case self::TYPE_WHISPER:
/** @noinspection PhpMissingBreakStatementInspection */ /** @noinspection PhpMissingBreakStatementInspection */
@ -94,14 +98,18 @@ class TextPacket extends DataPacket{
$this->putString($this->message); $this->putString($this->message);
break; break;
case self::TYPE_JUKEBOX_POPUP:
case self::TYPE_TRANSLATION: case self::TYPE_TRANSLATION:
case self::TYPE_POPUP:
case self::TYPE_JUKEBOX_POPUP:
$this->putString($this->message); $this->putString($this->message);
$this->putUnsignedVarInt(count($this->parameters)); $this->putUnsignedVarInt(count($this->parameters));
foreach($this->parameters as $p){ foreach($this->parameters as $p){
$this->putString($p); $this->putString($p);
} }
break;
} }
$this->putString($this->xboxUserId);
} }
public function handle(NetworkSession $session) : bool{ public function handle(NetworkSession $session) : bool{