mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Fix overrideable hand ToolCapabilities and range (#15743)
This commit is contained in:
parent
d085f0fb52
commit
e0378737b7
6 changed files with 42 additions and 32 deletions
|
@ -102,18 +102,27 @@ struct ItemStack
|
|||
}
|
||||
|
||||
// Get tool digging properties, or those of the hand if not a tool
|
||||
// If not hand assumes default hand ""
|
||||
const ToolCapabilities& getToolCapabilities(
|
||||
const IItemDefManager *itemdef) const
|
||||
const IItemDefManager *itemdef, const ItemStack *hand = nullptr) const
|
||||
{
|
||||
const ToolCapabilities *item_cap =
|
||||
itemdef->get(name).tool_capabilities;
|
||||
const ToolCapabilities *item_cap = itemdef->get(name).tool_capabilities;
|
||||
|
||||
if (item_cap == NULL)
|
||||
// Fall back to the hand's tool capabilities
|
||||
item_cap = itemdef->get("").tool_capabilities;
|
||||
if (item_cap) {
|
||||
return metadata.getToolCapabilities(*item_cap); // Check for override
|
||||
}
|
||||
|
||||
assert(item_cap != NULL);
|
||||
return metadata.getToolCapabilities(*item_cap); // Check for override
|
||||
// Fall back to the hand's tool capabilities
|
||||
if (hand) {
|
||||
item_cap = itemdef->get(hand->name).tool_capabilities;
|
||||
if (item_cap) {
|
||||
return hand->metadata.getToolCapabilities(*item_cap);
|
||||
}
|
||||
}
|
||||
|
||||
item_cap = itemdef->get("").tool_capabilities;
|
||||
assert(item_cap);
|
||||
return *item_cap;
|
||||
}
|
||||
|
||||
const std::optional<WearBarParams> &getWearBarParams(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue