Skip to content

Commit

Permalink
core.spawn_falling_node: Keep metadata (#7476)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker authored and nerzhul committed Jul 9, 2018
1 parent 498078b commit 0cf3645
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions builtin/game/falling.lua
Expand Up @@ -132,25 +132,26 @@ core.register_entity(":__builtin:falling_node", {
end
})

local function spawn_falling_node(p, node, meta)
local obj = core.add_entity(p, "__builtin:falling_node")
if obj then
obj:get_luaentity():set_node(node, meta)
local function convert_to_falling_node(pos, node)
local obj = core.add_entity(pos, "__builtin:falling_node")
if not obj then
return false
end
node.level = core.get_node_level(pos)
local meta = core.get_meta(pos)
local metatable = meta and meta:to_table() or {}

obj:get_luaentity():set_node(node, metatable)
core.remove_node(pos)
return true
end

function core.spawn_falling_node(pos)
local node = core.get_node(pos)
if node.name == "air" or node.name == "ignore" then
return false
end
local obj = core.add_entity(pos, "__builtin:falling_node")
if obj then
obj:get_luaentity():set_node(node)
core.remove_node(pos)
return true
end
return false
return convert_to_falling_node(pos, node)
end

local function drop_attached_node(p)
Expand Down Expand Up @@ -223,14 +224,7 @@ function core.check_single_for_falling(p)
core.get_node_max_level(p_bottom))) and

(not d_bottom.walkable or d_bottom.buildable_to) then
n.level = core.get_node_level(p)
local meta = core.get_meta(p)
local metatable = {}
if meta ~= nil then
metatable = meta:to_table()
end
core.remove_node(p)
spawn_falling_node(p, n, metatable)
convert_to_falling_node(p, n)
return true
end
end
Expand Down

0 comments on commit 0cf3645

Please sign in to comment.