mirror of
https://github.com/moparisthebest/minetest
synced 2024-11-16 14:25:19 -05:00
Prevent placing node when player would be inside new node
This commit is contained in:
parent
4896d4b829
commit
1b4908bf56
26
src/game.cpp
26
src/game.cpp
@ -905,9 +905,20 @@ bool nodePlacementPrediction(Client &client,
|
|||||||
// Add node to client map
|
// Add node to client map
|
||||||
MapNode n(id, 0, param2);
|
MapNode n(id, 0, param2);
|
||||||
try{
|
try{
|
||||||
|
LocalPlayer* player = client.getEnv().getLocalPlayer();
|
||||||
|
|
||||||
|
// Dont place node when player would be inside new node
|
||||||
|
// NOTE: This is to be eventually implemented by a mod as client-side Lua
|
||||||
|
if (!nodedef->get(n).walkable ||
|
||||||
|
(client.checkPrivilege("noclip") && g_settings->getBool("noclip")) ||
|
||||||
|
(nodedef->get(n).walkable &&
|
||||||
|
neighbourpos != player->getStandingNodePos() + v3s16(0,1,0) &&
|
||||||
|
neighbourpos != player->getStandingNodePos() + v3s16(0,2,0))) {
|
||||||
|
|
||||||
// This triggers the required mesh update too
|
// This triggers the required mesh update too
|
||||||
client.addNode(p, n);
|
client.addNode(p, n);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}catch(InvalidPositionException &e){
|
}catch(InvalidPositionException &e){
|
||||||
errorstream<<"Node placement prediction failed for "
|
errorstream<<"Node placement prediction failed for "
|
||||||
<<playeritem_def.name<<" (places "
|
<<playeritem_def.name<<" (places "
|
||||||
@ -2798,9 +2809,7 @@ void the_game(
|
|||||||
// Otherwise report right click to server
|
// Otherwise report right click to server
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Report to server
|
camera.setDigging(1); // right click animation (always shown for feedback)
|
||||||
client.interact(3, pointed);
|
|
||||||
camera.setDigging(1); // right click animation
|
|
||||||
|
|
||||||
// If the wielded item has node placement prediction,
|
// If the wielded item has node placement prediction,
|
||||||
// make that happen
|
// make that happen
|
||||||
@ -2808,14 +2817,21 @@ void the_game(
|
|||||||
playeritem_def,
|
playeritem_def,
|
||||||
nodepos, neighbourpos);
|
nodepos, neighbourpos);
|
||||||
|
|
||||||
|
if(placed) {
|
||||||
|
// Report to server
|
||||||
|
client.interact(3, pointed);
|
||||||
// Read the sound
|
// Read the sound
|
||||||
if(placed)
|
|
||||||
soundmaker.m_player_rightpunch_sound =
|
soundmaker.m_player_rightpunch_sound =
|
||||||
playeritem_def.sound_place;
|
playeritem_def.sound_place;
|
||||||
else
|
} else {
|
||||||
soundmaker.m_player_rightpunch_sound =
|
soundmaker.m_player_rightpunch_sound =
|
||||||
SimpleSoundSpec();
|
SimpleSoundSpec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playeritem_def.node_placement_prediction == "" ||
|
||||||
|
nodedef->get(map.getNode(nodepos)).rightclickable)
|
||||||
|
client.interact(3, pointed); // Report to server
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(pointed.type == POINTEDTHING_OBJECT)
|
else if(pointed.type == POINTEDTHING_OBJECT)
|
||||||
|
Loading…
Reference in New Issue
Block a user