}
};
-void nodePlacementPrediction(Client &client,
+bool nodePlacementPrediction(Client &client,
const ItemDefinition &playeritem_def,
v3s16 nodepos, v3s16 neighbourpos)
{
if(nodedef->get(n_under).buildable_to)
p = nodepos;
else if (!nodedef->get(map.getNode(p)).buildable_to)
- return;
+ return false;
}catch(InvalidPositionException &e){}
// Find id of predicted node
content_t id;
<<playeritem_def.name<<" (places "
<<prediction
<<") - Name not known"<<std::endl;
- return;
+ return false;
}
// Predict param2 for facedir and wallmounted nodes
u8 param2 = 0;
else
pp = p + v3s16(0,-1,0);
if(!nodedef->get(map.getNode(pp)).walkable)
- return;
+ return false;
}
// Add node to client map
MapNode n(id, 0, param2);
try{
// This triggers the required mesh update too
client.addNode(p, n);
+ return true;
}catch(InvalidPositionException &e){
errorstream<<"Node placement prediction failed for "
<<playeritem_def.name<<" (places "
<<") - Position not loaded"<<std::endl;
}
}
+ return false;
}
// If the wielded item has node placement prediction,
// make that happen
- nodePlacementPrediction(client,
+ bool placed = nodePlacementPrediction(client,
playeritem_def,
nodepos, neighbourpos);
// Read the sound
- soundmaker.m_player_rightpunch_sound =
- playeritem_def.sound_place;
+ if(placed)
+ soundmaker.m_player_rightpunch_sound =
+ playeritem_def.sound_place;
+ else
+ soundmaker.m_player_rightpunch_sound =
+ SimpleSoundSpec();
}
}
}