diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index 5699e1722..d39ceab3b 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -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); diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 9ddb289dc..349b55c0f 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -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); } } diff --git a/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php b/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php index 48d7f0130..455890fd0 100644 --- a/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/AddItemEntityPacket.php @@ -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{ diff --git a/src/pocketmine/network/mcpe/protocol/BatchPacket.php b/src/pocketmine/network/mcpe/protocol/BatchPacket.php index f68194152..98a10578e 100644 --- a/src/pocketmine/network/mcpe/protocol/BatchPacket.php +++ b/src/pocketmine/network/mcpe/protocol/BatchPacket.php @@ -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; } - $str = zlib_decode($this->payload, 1024 * 1024 * 64); //Max 64MB - $len = strlen($str); + try{ + $str = zlib_decode($this->payload, 1024 * 1024 * 64); //Max 64MB + }catch(\ErrorException $e){ + return false; + } - if($len === 0){ + if(strlen($str) === 0){ throw new \InvalidStateException("Decoded BatchPacket payload is empty"); } diff --git a/src/pocketmine/network/mcpe/protocol/LoginPacket.php b/src/pocketmine/network/mcpe/protocol/LoginPacket.php index b8a596475..d01692256 100644 --- a/src/pocketmine/network/mcpe/protocol/LoginPacket.php +++ b/src/pocketmine/network/mcpe/protocol/LoginPacket.php @@ -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); diff --git a/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php b/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php index 6e62b8041..a666b98c7 100644 --- a/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php +++ b/src/pocketmine/network/mcpe/protocol/MoveEntityPacket.php @@ -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{ diff --git a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php index 0e756fbc8..d5c71d6d6 100644 --- a/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php +++ b/src/pocketmine/network/mcpe/protocol/ProtocolInfo.php @@ -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;