mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Clamp hotbar selection to slots that exist (#14869)
This commit is contained in:
parent
39c2af9710
commit
98e51a0159
8 changed files with 51 additions and 11 deletions
|
@ -88,6 +88,11 @@ void Player::setWieldIndex(u16 index)
|
|||
m_wield_index = MYMIN(index, mlist ? mlist->getSize() : 0);
|
||||
}
|
||||
|
||||
u16 Player::getWieldIndex()
|
||||
{
|
||||
return std::min(m_wield_index, getMaxHotbarItemcount());
|
||||
}
|
||||
|
||||
ItemStack &Player::getWieldedItem(ItemStack *selected, ItemStack *hand) const
|
||||
{
|
||||
assert(selected);
|
||||
|
@ -157,6 +162,12 @@ void Player::clearHud()
|
|||
}
|
||||
}
|
||||
|
||||
u16 Player::getMaxHotbarItemcount()
|
||||
{
|
||||
InventoryList *mainlist = inventory.getList("main");
|
||||
return mainlist ? std::min(mainlist->getSize(), (u32) hud_hotbar_itemcount) : 0;
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
|
||||
u32 PlayerControl::getKeysPressed() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue