From 015b1fafff2ebdd77b9b9cc0e240d9233d1ed331 Mon Sep 17 00:00:00 2001 From: Aaron Suen Date: Thu, 20 Oct 2022 07:22:45 -0400 Subject: [PATCH] Digging light sources leaves dynamic light behind briefly This helps to bridge the latency gap between the dig completing on the client side, and the server sending the result, which might include adding dynamic lights from a now-handheld light emitter, e.g. for torches or lanterns. --- mods/nc_api_active/dynalight.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mods/nc_api_active/dynalight.lua b/mods/nc_api_active/dynalight.lua index 79215de0..05b59f7e 100644 --- a/mods/nc_api_active/dynalight.lua +++ b/mods/nc_api_active/dynalight.lua @@ -229,3 +229,15 @@ function nodecore.dynamic_shade_add(pos, above) }, above - 1) end end + +-- When digging a node that emits light when placed, and would +-- emit light when held, there can be a brief flicker of darkness +-- when MT predicts the dug node is gone but the dynamic light +-- hasn't been send to the player yet. + +nodecore.register_on_register_item(function(_, def) + if def.light_source and def.light_source > 0 + and def.node_dig_prediction == nil then + def.node_dig_prediction = modname .. ":light" .. def.light_source + end + end)