nodecore-cd2025/mods/nc_api/item_diggable.lua
Aaron Suen 8f452a48fe Fix digging undiggables at high lag
Apparently (e.g. on Kimapr's servers) it's possible
to dig "undiggable" nodes under extreme lag.

Theory:

- Place something like cobble next to water source
- Dig with infused mattock through all stages

The client will predict a cobble->loose cobble
transition, then let you dig the loose cobble, and
then send the "dig" command to the server, but
on the server side the cobble instead was dug
directly, and then water flowed in to fill the space
where the client thought the loose cobble would
be, so the client digs the water, and you get
flowing water in your inventory.
2021-03-16 20:19:11 -04:00

35 lines
741 B
Lua

-- LUALOCALS < ---------------------------------------------------------
local nodecore, pairs, type
= nodecore, pairs, type
-- LUALOCALS > ---------------------------------------------------------
local diggroups = {
cracky = true,
choppy = true,
crumbly = true,
snappy = true
}
nodecore.register_on_register_item(function(_, def)
if def.diggable ~= nil then return end
if def.pointable == false then
def.diggable = false
return
end
if def.liquidtype ~= nil and def.liquidtype ~= "none" then
def.diggable = false
return
end
if def.groups then
for k in pairs(diggroups) do
if type(def.groups[k]) == "number" and def.groups[k] > 0 then
return
end
end
end
def.diggable = false
end)