Skip to content

Commit

Permalink
Remove buildable_to nodes without dropping item when replaced by a fa…
Browse files Browse the repository at this point in the history
…lling node
  • Loading branch information
CasimirKaPazi authored and sapier committed Aug 22, 2014
1 parent d9df592 commit 08f7ac5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions builtin/game/falling.lua
Expand Up @@ -79,17 +79,24 @@ core.register_entity(":__builtin:falling_node", {
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
-- Check what's here
local n2 = core.get_node(np)
-- remove node and replace it with it's drops
local drops = core.get_node_drops(n2.name, "")
core.remove_node(np)
local _, dropped_item
for _, dropped_item in ipairs(drops) do
core.add_item(np, dropped_item)
end
-- Run script hook
local _, callback
for _, callback in ipairs(core.registered_on_dignodes) do
callback(np, n2, nil)
-- If it's not air or liquid, remove node and replace it with
-- it's drops
if n2.name ~= "air" and (not core.registered_nodes[n2.name] or
core.registered_nodes[n2.name].liquidtype == "none") then
core.remove_node(np)
if core.registered_nodes[n2.name].buildable_to == false then
-- Add dropped items
local drops = core.get_node_drops(n2.name, "")
local _, dropped_item
for _, dropped_item in ipairs(drops) do
core.add_item(np, dropped_item)
end
end
-- Run script hook
local _, callback
for _, callback in ipairs(core.registered_on_dignodes) do
callback(np, n2, nil)
end
end
-- Create node and remove entity
core.add_node(np, self.node)
Expand Down

1 comment on commit 08f7ac5

@HybridDog
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test if the node is allowed to become removed,
walkable and/or plantlike nodes' inventories, if they have one and something like sand falls into them, disappear even if this is disallowed, e.g. these red bones.

Please sign in to comment.