Disallow hurting objects with items that have the "nohit" group (#51)

This commit is contained in:
sfan5 2017-03-11 20:50:51 +01:00 committed by Maksim Gamarnik
parent c022289648
commit a9f632b499
1 changed files with 6 additions and 2 deletions

View File

@ -3880,7 +3880,11 @@ void Game::handlePointingAtObject(GameRunData *runData,
runData->selected_object->debugInfoText())); 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 = false;
bool do_punch_damage = false; bool do_punch_damage = false;
@ -3910,7 +3914,7 @@ void Game::handlePointingAtObject(GameRunData *runData,
if (!disable_send) if (!disable_send)
client->interact(0, pointed); client->interact(0, pointed);
} }
} else if (input->getRightClicked()) { } else if (input->getRightClicked() || (input->getLeftClicked() && nohit_enabled)) {
infostream << "Right-clicked object" << std::endl; infostream << "Right-clicked object" << std::endl;
client->interact(3, pointed); // place client->interact(3, pointed); // place
} }