1
0
Fork 0
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:
raymoo 2017-04-18 16:30:27 -07:00 committed by paramat
parent 610ea6f216
commit a637107a4e
10 changed files with 206 additions and 14 deletions

View file

@ -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)