Skip to content

Commit 08f7ac5

Browse files
CasimirKaPazisapier
authored and
sapier
committedAug 22, 2014
Remove buildable_to nodes without dropping item when replaced by a falling node
1 parent d9df592 commit 08f7ac5

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed
 

‎builtin/game/falling.lua

+18-11
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,24 @@ core.register_entity(":__builtin:falling_node", {
7979
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
8080
-- Check what's here
8181
local n2 = core.get_node(np)
82-
-- remove node and replace it with it's drops
83-
local drops = core.get_node_drops(n2.name, "")
84-
core.remove_node(np)
85-
local _, dropped_item
86-
for _, dropped_item in ipairs(drops) do
87-
core.add_item(np, dropped_item)
88-
end
89-
-- Run script hook
90-
local _, callback
91-
for _, callback in ipairs(core.registered_on_dignodes) do
92-
callback(np, n2, nil)
82+
-- If it's not air or liquid, remove node and replace it with
83+
-- it's drops
84+
if n2.name ~= "air" and (not core.registered_nodes[n2.name] or
85+
core.registered_nodes[n2.name].liquidtype == "none") then
86+
core.remove_node(np)
87+
if core.registered_nodes[n2.name].buildable_to == false then
88+
-- Add dropped items
89+
local drops = core.get_node_drops(n2.name, "")
90+
local _, dropped_item
91+
for _, dropped_item in ipairs(drops) do
92+
core.add_item(np, dropped_item)
93+
end
94+
end
95+
-- Run script hook
96+
local _, callback
97+
for _, callback in ipairs(core.registered_on_dignodes) do
98+
callback(np, n2, nil)
99+
end
93100
end
94101
-- Create node and remove entity
95102
core.add_node(np, self.node)

1 commit comments

Comments
 (1)

HybridDog commented on Aug 22, 2014

@HybridDog
Contributor

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.