Protocol updates for 1.1.0.5

This commit is contained in:
Dylan K. Taylor 2017-04-20 13:54:55 +01:00
parent 17e4f45e97
commit 6c5ca9b256
7 changed files with 35 additions and 10 deletions

View File

@ -129,6 +129,13 @@ namespace pocketmine {
set_time_limit(0); //Who set it to 30 seconds?!?!
error_reporting(-1);
set_error_handler(function($severity, $message, $file, $line){
if((error_reporting() & $severity)){
throw new \ErrorException($message, 0, $severity, $file, $line);
}
});
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);

View File

@ -234,10 +234,9 @@ class Item extends Entity{
$pk->speedY = $this->motionY;
$pk->speedZ = $this->motionZ;
$pk->item = $this->getItem();
$pk->metadata = $this->dataProperties;
$player->dataPacket($pk);
$this->sendData($player);
parent::spawnTo($player);
}
}

View File

@ -37,6 +37,7 @@ class AddItemEntityPacket extends DataPacket{
public $speedX;
public $speedY;
public $speedZ;
public $metadata = [];
public function decode(){
@ -49,6 +50,7 @@ class AddItemEntityPacket extends DataPacket{
$this->putSlot($this->item);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putVector3f($this->speedX, $this->speedY, $this->speedZ);
$this->putEntityMetadata($this->metadata);
}
public function handle(NetworkSession $session) : bool{

View File

@ -74,13 +74,16 @@ class BatchPacket extends DataPacket{
public function handle(NetworkSession $session) : bool{
if(strlen($this->payload) < 2){
throw new \InvalidStateException("Not enough bytes in payload, expected zlib header");
return false;
}
try{
$str = zlib_decode($this->payload, 1024 * 1024 * 64); //Max 64MB
$len = strlen($str);
}catch(\ErrorException $e){
return false;
}
if($len === 0){
if(strlen($str) === 0){
throw new \InvalidStateException("Decoded BatchPacket payload is empty");
}

View File

@ -62,7 +62,19 @@ class LoginPacket extends DataPacket{
$this->gameEdition = $this->getByte();
$str = zlib_decode($this->getString(), 1024 * 1024 * 64);
$str = $this->getString();
//TODO: remove this hack once the protocol gets bumped
if($str{0} === "\x78"){
try{
$str = zlib_decode($str, 1024 * 1024 * 64);
$this->protocol = 0;
$this->buffer = null; // <= 1.1.0.4
return;
}catch(\ErrorException $e){
// >= 1.1.0.5
}
}
$this->setBuffer($str, 0);

View File

@ -37,6 +37,7 @@ class MoveEntityPacket extends DataPacket{
public $headYaw;
public $pitch;
public $byte1;
public $byte2;
public function decode(){
$this->eid = $this->getEntityRuntimeId();
@ -52,9 +53,10 @@ class MoveEntityPacket extends DataPacket{
$this->putEntityRuntimeId($this->eid);
$this->putVector3f($this->x, $this->y, $this->z);
$this->putByte($this->pitch / (360.0 / 256));
$this->putByte($this->yaw / (360.0 / 256));
$this->putByte($this->headYaw / (360.0 / 256));
$this->putByte($this->yaw / (360.0 / 256));
$this->putByte($this->byte1);
$this->putByte($this->byte2);
}
public function handle(NetworkSession $session) : bool{

View File

@ -32,8 +32,8 @@ interface ProtocolInfo{
* Actual Minecraft: PE protocol version
*/
const CURRENT_PROTOCOL = 110;
const MINECRAFT_VERSION = 'v1.1.0.3 beta';
const MINECRAFT_VERSION_NETWORK = '1.1.0.3';
const MINECRAFT_VERSION = 'v1.1.0.5 beta';
const MINECRAFT_VERSION_NETWORK = '1.1.0.5';
const LOGIN_PACKET = 0x01;
const PLAY_STATUS_PACKET = 0x02;