1
0
Fork 0
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:
SmallJoker 2019-09-21 11:44:24 +02:00 committed by GitHub
parent 47da640d77
commit 5fa614d97e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 41 deletions

View file

@ -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;
}