mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 00:55:20 +02: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:
12
src/game.cpp
12
src/game.cpp
@@ -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);
|
||||
|
Reference in New Issue
Block a user