mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-15 01:25:20 +02: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:
@@ -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)
|
||||
|
Reference in New Issue
Block a user