diff options
Diffstat (limited to 'builtin/game/item.lua')
-rw-r--r-- | builtin/game/item.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 5e5696ff5..a7176711f 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -579,6 +579,20 @@ function core.node_dig(pos, node, digger) digger:set_wielded_item(wielded) end + -- Check to see if metadata should be preserved. + if def and def.preserve_metadata then + local oldmeta = core.get_meta(pos):to_table().fields + -- Copy pos and node because the callback can modify them. + local pos_copy = {x=pos.x, y=pos.y, z=pos.z} + local node_copy = {name=node.name, param1=node.param1, param2=node.param2} + local drop_stacks = {} + for k, v in pairs(drops) do + drop_stacks[k] = ItemStack(v) + end + drops = drop_stacks + def.preserve_metadata(pos_copy, node_copy, oldmeta, drops) + end + -- Handle drops core.handle_node_drops(pos, drops, digger) |