mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
Wieldhand: Specify which ItemStack to use (#8961)
Makes 'get_wield_item' to return the "main" ItemStack
This commit is contained in:
parent
47da640d77
commit
5fa614d97e
7 changed files with 37 additions and 41 deletions
|
@ -68,25 +68,16 @@ float ServerActiveObject::getMinimumSavedMovement()
|
|||
return 2.0*BS;
|
||||
}
|
||||
|
||||
ItemStack ServerActiveObject::getWieldedItem() const
|
||||
ItemStack ServerActiveObject::getWieldedItem(ItemStack *selected, ItemStack *hand) const
|
||||
{
|
||||
const Inventory *inv = getInventory();
|
||||
if(inv)
|
||||
{
|
||||
const InventoryList *list = inv->getList(getWieldList());
|
||||
if(list && (getWieldIndex() < (s32)list->getSize()))
|
||||
return list->getItem(getWieldIndex());
|
||||
}
|
||||
*selected = ItemStack();
|
||||
if (hand)
|
||||
*hand = ItemStack();
|
||||
|
||||
return ItemStack();
|
||||
}
|
||||
|
||||
bool ServerActiveObject::setWieldedItem(const ItemStack &item)
|
||||
{
|
||||
if(Inventory *inv = getInventory()) {
|
||||
if (InventoryList *list = inv->getList(getWieldList())) {
|
||||
list->changeItem(getWieldIndex(), item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue