mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-07 16:48:40 +00:00
Allow overriding tool capabilities through itemstack metadata
This makes it possible to modify the tool capabilities of individual itemstacks by calling a method on itemstack metadata references.
This commit is contained in:
parent
610ea6f216
commit
a637107a4e
10 changed files with 206 additions and 14 deletions
|
@ -111,12 +111,15 @@ struct ItemStack
|
|||
const ToolCapabilities& getToolCapabilities(
|
||||
IItemDefManager *itemdef) const
|
||||
{
|
||||
ToolCapabilities *cap;
|
||||
cap = itemdef->get(name).tool_capabilities;
|
||||
if(cap == NULL)
|
||||
cap = itemdef->get("").tool_capabilities;
|
||||
assert(cap != NULL);
|
||||
return *cap;
|
||||
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;
|
||||
|
||||
assert(item_cap != NULL);
|
||||
return metadata.getToolCapabilities(*item_cap); // Check for override
|
||||
}
|
||||
|
||||
// Wear out (only tools)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue