Skip to content

Commit

Permalink
Play place_failed sound if occupied or cannot attach (#9486)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wuzzy2 committed Jul 27, 2020
1 parent 808fa5e commit ae83edd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions doc/lua_api.txt
Expand Up @@ -7217,10 +7217,13 @@ Used by `minetest.register_node`.
-- Node was placed. Also played after falling

place_failed = <SimpleSoundSpec>,
-- When node placement failed
-- When node placement failed.
-- Note: This happens if the _built-in_ node placement failed.
-- This sound will still be played if the node is placed in the
-- `on_place` callback manually.

fall = <SimpleSoundSpec>,
-- When node starts to fall
-- When node starts to fall or is detached
},

drop = "",
Expand Down
2 changes: 2 additions & 0 deletions src/client/game.cpp
Expand Up @@ -3379,6 +3379,7 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
} else {
node = map.getNode(p, &is_valid_position);
if (is_valid_position && !nodedef->get(node).buildable_to) {
soundmaker->m_player_rightpunch_sound = selected_def.sound_place_failed;
// Report to server
client->interact(INTERACT_PLACE, pointed);
return false;
Expand Down Expand Up @@ -3451,6 +3452,7 @@ bool Game::nodePlacement(const ItemDefinition &selected_def,
pp = p + v3s16(0, -1, 0);

if (!nodedef->get(map.getNode(pp)).walkable) {
soundmaker->m_player_rightpunch_sound = selected_def.sound_place_failed;
// Report to server
client->interact(INTERACT_PLACE, pointed);
return false;
Expand Down

0 comments on commit ae83edd

Please sign in to comment.