NetworkSession: Fixed InventoryManager nullability disaster

fixes #4277
fixes #4275
fixes #3139
This commit is contained in:
Dylan K. Taylor
2021-06-26 17:44:42 +01:00
parent e43bca95bf
commit 0910054c41
8 changed files with 74 additions and 48 deletions

View File

@ -39,6 +39,7 @@ use pocketmine\item\ItemFactory;
use pocketmine\item\ItemIds;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\IntTag;
use pocketmine\network\mcpe\InventoryManager;
use pocketmine\network\mcpe\protocol\types\GameMode as ProtocolGameMode;
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
@ -240,7 +241,7 @@ class TypeConverter{
/**
* @throws \UnexpectedValueException
*/
public function createInventoryAction(NetworkInventoryAction $action, Player $player) : ?InventoryAction{
public function createInventoryAction(NetworkInventoryAction $action, Player $player, InventoryManager $inventoryManager) : ?InventoryAction{
if($action->oldItem->getItemStack()->equals($action->newItem->getItemStack())){
//filter out useless noise in 1.13
return null;
@ -276,7 +277,7 @@ class TypeConverter{
}
[$slot, $window] = $mapped;
}else{
$window = $player->getNetworkSession()->getInvManager()->getWindow($action->windowId);
$window = $inventoryManager->getWindow($action->windowId);
$slot = $action->inventorySlot;
}
if($window !== null){