InventoryManager: give more detailed information on failure to get info for held item

This commit is contained in:
Dylan K. Taylor 2023-03-27 17:55:39 +01:00
parent 3ee62d8440
commit af385668c2
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -576,9 +576,13 @@ class InventoryManager{
$playerInventory = $this->player->getInventory();
$selected = $playerInventory->getHeldItemIndex();
if($selected !== $this->clientSelectedHotbarSlot){
$itemStackInfo = $this->getItemStackInfo($playerInventory, $selected);
$inventoryEntry = $this->inventories[spl_object_id($playerInventory)] ?? null;
if($inventoryEntry === null){
throw new AssumptionFailedError("Player inventory should always be tracked");
}
$itemStackInfo = $inventoryEntry->itemStackInfos[$selected] ?? null;
if($itemStackInfo === null){
throw new AssumptionFailedError("Player inventory slots should always be tracked");
throw new AssumptionFailedError("Untracked player inventory slot $selected");
}
$this->session->sendDataPacket(MobEquipmentPacket::create(