mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-12 16:58:39 +00:00
Fix problems when overriding the hand:
- If the hand can dig a node the item wielded can't, allow to dig it anyway. - Fix the API callbacks from setting the hand instead of the wielded item.
This commit is contained in:
parent
bce0d458d8
commit
08b680d588
4 changed files with 38 additions and 20 deletions
|
@ -1271,6 +1271,16 @@ std::string PlayerSAO::getWieldList() const
|
|||
}
|
||||
|
||||
ItemStack PlayerSAO::getWieldedItem() const
|
||||
{
|
||||
const Inventory *inv = getInventory();
|
||||
ItemStack ret;
|
||||
const InventoryList *mlist = inv->getList(getWieldList());
|
||||
if (mlist && getWieldIndex() < (s32)mlist->getSize())
|
||||
ret = mlist->getItem(getWieldIndex());
|
||||
return ret;
|
||||
}
|
||||
|
||||
ItemStack PlayerSAO::getWieldedItemOrHand() const
|
||||
{
|
||||
const Inventory *inv = getInventory();
|
||||
ItemStack ret;
|
||||
|
@ -1291,14 +1301,6 @@ bool PlayerSAO::setWieldedItem(const ItemStack &item)
|
|||
if (inv) {
|
||||
InventoryList *mlist = inv->getList(getWieldList());
|
||||
if (mlist) {
|
||||
ItemStack olditem = mlist->getItem(getWieldIndex());
|
||||
if (olditem.name.empty()) {
|
||||
InventoryList *hlist = inv->getList("hand");
|
||||
if (hlist) {
|
||||
hlist->changeItem(0, item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
mlist->changeItem(getWieldIndex(), item);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue