diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 3d1cbb3b2..c942ff8dc 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -2238,7 +2238,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($packet->inventorySlot === 255){ $packet->inventorySlot = -1; //Cleared slot }else{ + if($packet->inventorySlot < 9){ + $this->server->getLogger()->debug("Tried to equip a slot that does not exist (index " . $packet->inventorySlot . ")"); + $this->inventory->sendContents($this); + return false; + } $packet->inventorySlot -= 9; //Get real inventory slot + $item = $this->inventory->getItem($packet->inventorySlot); if(!$item->equals($packet->item)){ @@ -3336,8 +3342,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $timings->startTiming(); $packet->decode(); - assert($packet->feof(), "Still " . strlen(substr($packet->buffer, $packet->offset)) . " bytes unread in " . get_class($packet)); - + if(!$packet->feof()){ + $this->server->getLogger()->debug("Still " . strlen(substr($packet->buffer, $packet->offset)) . " bytes unread in " . get_class($packet) . " from " . $this->getName() . ": " . bin2hex($packet->get(true))); + } $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet)); if(!$ev->isCancelled() and !$packet->handle($this)){ $this->server->getLogger()->debug("Unhandled " . get_class($packet) . " received from " . $this->getName() . ": " . bin2hex($packet->buffer)); diff --git a/src/pocketmine/utils/BinaryStream.php b/src/pocketmine/utils/BinaryStream.php index 156ce4523..0060e12ac 100644 --- a/src/pocketmine/utils/BinaryStream.php +++ b/src/pocketmine/utils/BinaryStream.php @@ -201,6 +201,8 @@ class BinaryStream extends \stdClass{ $nbt = $this->get($nbtLen); } + $this->get(2); //??? (TODO) + return Item::get( $id, $data, @@ -222,6 +224,7 @@ class BinaryStream extends \stdClass{ $nbt = $item->getCompoundTag(); $this->putLShort(strlen($nbt)); $this->put($nbt); + $this->put("\x00\x00"); //TODO: find out what these are } public function getString(){