From a9f632b4994a0f3efc56b7b3b20d7f4220119a7c Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sat, 11 Mar 2017 20:50:51 +0100 Subject: [PATCH] Disallow hurting objects with items that have the "nohit" group (#51) --- src/game.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 08d3f4e8b..f2653cd0f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3880,7 +3880,11 @@ void Game::handlePointingAtObject(GameRunData *runData, runData->selected_object->debugInfoText())); } - if (input->getLeftState()) { + const ItemDefinition &playeritem_def = + playeritem.getDefinition(itemdef_manager); + bool nohit_enabled = ((ItemGroupList) playeritem_def.groups)["attached_node"] != 0; + + if (input->getLeftState() && !nohit_enabled) { bool do_punch = false; bool do_punch_damage = false; @@ -3910,7 +3914,7 @@ void Game::handlePointingAtObject(GameRunData *runData, if (!disable_send) client->interact(0, pointed); } - } else if (input->getRightClicked()) { + } else if (input->getRightClicked() || (input->getLeftClicked() && nohit_enabled)) { infostream << "Right-clicked object" << std::endl; client->interact(3, pointed); // place }