mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
Fixed inventory crash, fixed crafting
This commit is contained in:
parent
9c25ec3afd
commit
f7e959d602
@ -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));
|
||||
|
@ -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(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user