aboutsummaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorraymoo <uguu@installgentoo.com>2017-04-18 16:30:27 -0700
committerparamat <mat.gregory@virginmedia.com>2017-10-29 11:57:38 +0000
commita637107a4e81be88938d68df4deae50e68cf2cd8 (patch)
tree2d35b9bf380af88bb7618a6b4efbca6f55c338d3 /src/game.cpp
parent610ea6f21629933be3b38c2b5fce53a35c5aac3a (diff)
downloadminetest-a637107a4e81be88938d68df4deae50e68cf2cd8.tar.gz
minetest-a637107a4e81be88938d68df4deae50e68cf2cd8.tar.bz2
minetest-a637107a4e81be88938d68df4deae50e68cf2cd8.zip
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.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/game.cpp b/src/game.cpp
index cd4650baf..fd3914356 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3701,8 +3701,13 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug)
} else if (pointed.type == POINTEDTHING_NODE) {
ToolCapabilities playeritem_toolcap =
playeritem.getToolCapabilities(itemdef_manager);
- if (playeritem.name.empty() && hand_def.tool_capabilities != NULL) {
- playeritem_toolcap = *hand_def.tool_capabilities;
+ if (playeritem.name.empty()) {
+ const ToolCapabilities *handToolcap = hlist
+ ? &hlist->getItem(0).getToolCapabilities(itemdef_manager)
+ : itemdef_manager->get("").tool_capabilities;
+
+ if (handToolcap != nullptr)
+ playeritem_toolcap = *handToolcap;
}
handlePointingAtNode(pointed, playeritem_def, playeritem,
playeritem_toolcap, dtime);
@@ -4004,9 +4009,9 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
// If can't dig, try hand
if (!params.diggable) {
InventoryList *hlist = local_inventory->getList("hand");
- const ItemDefinition &hand =
- hlist ? hlist->getItem(0).getDefinition(itemdef_manager) : itemdef_manager->get("");
- const ToolCapabilities *tp = hand.tool_capabilities;
+ const ToolCapabilities *tp = hlist
+ ? &hlist->getItem(0).getToolCapabilities(itemdef_manager)
+ : itemdef_manager->get("").tool_capabilities;
if (tp)
params = getDigParams(nodedef_manager->get(n).groups, tp);