Fixed inventory crash, fixed crafting

This commit is contained in:
Dylan K. Taylor 2017-04-02 10:58:39 +01:00
parent 9c25ec3afd
commit f7e959d602
2 changed files with 12 additions and 2 deletions

View File

@ -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));

View File

@ -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(){