mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Improve inventory command output (#1582)
* Improve inventory command output * Remove unused code * Sort item list before printing * Fix incorrect container slot count * Update Container.IsHotbar method
This commit is contained in:
parent
1cd7c098c3
commit
073458f5f2
4 changed files with 78 additions and 38 deletions
|
|
@ -191,5 +191,29 @@ namespace MinecraftClient.Inventory
|
|||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check the given slot ID is a hotbar slot and give the hotbar number
|
||||
/// </summary>
|
||||
/// <param name="slotId">The slot ID to check</param>
|
||||
/// <param name="hotbar">Zero-based, 0-8. -1 if not a hotbar</param>
|
||||
/// <returns>True if given slot ID is a hotbar slot</returns>
|
||||
public bool IsHotbar(int slotId, out int hotbar)
|
||||
{
|
||||
int hotbarStart = Type.SlotCount() - 9;
|
||||
// Remove offhand slot
|
||||
if (Type == ContainerType.PlayerInventory)
|
||||
hotbarStart--;
|
||||
if ((slotId >= hotbarStart) && (slotId <= hotbarStart + 9))
|
||||
{
|
||||
hotbar = slotId - hotbarStart;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hotbar = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue