on ground when the player places the item. Server will always update
actual result to client in a short moment.
]]
+ node_dig_prediction = "air",
+ --[[
+ ^ if "", no prediction is made
+ ^ if "air", node is removed
+ ^ Otherwise should be name of node which the client immediately places
+ upon digging. Server will always update actual result shortly.
+ ]]
sound = {
breaks = "default_tool_break", -- tools only
place = --[[<SimpleSoundSpec>]],
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);
color = video::SColor(0xFFFFFFFF);
palette_name = "";
palette = NULL;
+ node_dig_prediction = "air";
}
void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) const
// legacy
writeU8(os, legacy_facedir_simple);
writeU8(os, legacy_wallmounted);
+
+ os << serializeString(node_dig_prediction);
}
void ContentFeatures::correctAlpha(TileDef *tiles, int length)
// read legacy properties
legacy_facedir_simple = readU8(is);
legacy_wallmounted = readU8(is);
+
+ try {
+ node_dig_prediction = deSerializeString(is);
+ } catch(SerializationError &e) {};
}
#ifndef SERVER
// Player cannot build to these (placement prediction disabled)
bool rightclickable;
u32 damage_per_second;
+ // client dig prediction
+ std::string node_dig_prediction;
// --- LIQUID PROPERTIES ---
}
lua_pop(L, 1);
+ // Node immediately placed by client when node is dug
+ getstringfield(L, index, "node_dig_prediction",
+ f.node_dig_prediction);
+
return f;
}
lua_setfield(L, -2, "legacy_facedir_simple");
lua_pushboolean(L, c.legacy_wallmounted);
lua_setfield(L, -2, "legacy_wallmounted");
+ lua_pushstring(L, c.node_dig_prediction.c_str());
+ lua_setfield(L, -2, "node_dig_prediction");
}
/******************************************************************************/