1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Implement client node dig prediction

Dig prediction allows clients to remove dug nodes without
waiting for server acknowledgement.
This patch allows mods to override dig prediction,
it can either be turned off or a different "prediction node"
can be selected.
This commit is contained in:
Auke Kok 2017-09-11 14:50:06 +02:00 committed by sfan5
parent d10cccee31
commit 5b3fbf9cf7
5 changed files with 33 additions and 1 deletions

View file

@ -4104,7 +4104,17 @@ void Game::handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
client->getScript()->on_dignode(nodepos, wasnode)) {
return;
}
client->removeNode(nodepos);
const ContentFeatures &f = client->ndef()->get(wasnode);
if (f.node_dig_prediction == "air") {
client->removeNode(nodepos);
} else if (!f.node_dig_prediction.empty()) {
content_t id;
bool found = client->ndef()->getId(f.node_dig_prediction, id);
if (found)
client->addNode(nodepos, id, true);
}
// implicit else: no prediction
}
client->interact(2, pointed);