@@ -834,7 +834,7 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
834
834
}
835
835
};
836
836
837
- void nodePlacementPrediction (Client &client,
837
+ bool nodePlacementPrediction (Client &client,
838
838
const ItemDefinition &playeritem_def,
839
839
v3s16 nodepos, v3s16 neighbourpos)
840
840
{
@@ -854,7 +854,7 @@ void nodePlacementPrediction(Client &client,
854
854
if (nodedef->get (n_under).buildable_to )
855
855
p = nodepos;
856
856
else if (!nodedef->get (map.getNode (p)).buildable_to )
857
- return ;
857
+ return false ;
858
858
}catch (InvalidPositionException &e){}
859
859
// Find id of predicted node
860
860
content_t id;
@@ -864,7 +864,7 @@ void nodePlacementPrediction(Client &client,
864
864
<<playeritem_def.name <<" (places "
865
865
<<prediction
866
866
<<" ) - Name not known" <<std::endl;
867
- return ;
867
+ return false ;
868
868
}
869
869
// Predict param2 for facedir and wallmounted nodes
870
870
u8 param2 = 0 ;
@@ -903,20 +903,22 @@ void nodePlacementPrediction(Client &client,
903
903
else
904
904
pp = p + v3s16 (0 ,-1 ,0 );
905
905
if (!nodedef->get (map.getNode (pp)).walkable )
906
- return ;
906
+ return false ;
907
907
}
908
908
// Add node to client map
909
909
MapNode n (id, 0 , param2);
910
910
try {
911
911
// This triggers the required mesh update too
912
912
client.addNode (p, n);
913
+ return true ;
913
914
}catch (InvalidPositionException &e){
914
915
errorstream<<" Node placement prediction failed for "
915
916
<<playeritem_def.name <<" (places "
916
917
<<prediction
917
918
<<" ) - Position not loaded" <<std::endl;
918
919
}
919
920
}
921
+ return false ;
920
922
}
921
923
922
924
@@ -2774,13 +2776,17 @@ void the_game(
2774
2776
2775
2777
// If the wielded item has node placement prediction,
2776
2778
// make that happen
2777
- nodePlacementPrediction (client,
2779
+ bool placed = nodePlacementPrediction (client,
2778
2780
playeritem_def,
2779
2781
nodepos, neighbourpos);
2780
2782
2781
2783
// Read the sound
2782
- soundmaker.m_player_rightpunch_sound =
2783
- playeritem_def.sound_place ;
2784
+ if (placed)
2785
+ soundmaker.m_player_rightpunch_sound =
2786
+ playeritem_def.sound_place ;
2787
+ else
2788
+ soundmaker.m_player_rightpunch_sound =
2789
+ SimpleSoundSpec ();
2784
2790
}
2785
2791
}
2786
2792
}
0 commit comments