Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prevent placing node when player would be inside new node
  • Loading branch information
BlockMen committed Jan 15, 2014
1 parent 4896d4b commit 1b4908b
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/game.cpp
Expand Up @@ -905,9 +905,20 @@ bool nodePlacementPrediction(Client &client,
// Add node to client map
MapNode n(id, 0, param2);
try{
// This triggers the required mesh update too
client.addNode(p, n);
return true;
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
client.addNode(p, n);
return true;
}
}catch(InvalidPositionException &e){
errorstream<<"Node placement prediction failed for "
<<playeritem_def.name<<" (places "
Expand Down Expand Up @@ -2798,23 +2809,28 @@ void the_game(
// Otherwise report right click to server
else
{
// Report to server
client.interact(3, pointed);
camera.setDigging(1); // right click animation

camera.setDigging(1); // right click animation (always shown for feedback)

// If the wielded item has node placement prediction,
// make that happen
bool placed = nodePlacementPrediction(client,
playeritem_def,
nodepos, neighbourpos);

// Read the sound
if(placed)
playeritem_def,
nodepos, neighbourpos);

if(placed) {
// Report to server
client.interact(3, pointed);
// Read the sound
soundmaker.m_player_rightpunch_sound =
playeritem_def.sound_place;
else
playeritem_def.sound_place;
} else {
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
}
}
}
Expand Down

4 comments on commit 1b4908b

@Sokomine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this sounds like a good idea at first, it can in some situations - narrow rooms - make it extremly difficult or even impossible to place nodes wiith facedir. The screwdriver is a test of patience on non-local servers and wears out very fast - nothing you want to require for even more nodes. Also pillaring up in order to reach upper floors and place nodes there became extremly difficult with this change.
Please consider finding a better solution or add a way to disable this.

@BlockMen
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sokomine, only on "rooms" that are 1 block small. And its just realistic that you can't place them in complicated ways in such narrow places. When you mean building up yourself with "pillaring up" then i was not able to notice any problems.
And in general: Its just wrong to place a node and then just jump out of it.

@PhoenixRiver
Copy link

@PhoenixRiver PhoenixRiver commented on 1b4908b Jan 18, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sokomine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic and RL cannot always be applied to gameplay. Some things have to be diffrent/illogical in order to work out. This "feature" unfortionately is something that severely annoys me as it renders building more difficult. We do not need player-unfriendly controls - perhaps that's something for extreme survival or something like that - we need controls that enable players to build well.

Please sign in to comment.