mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Remove buildable_to nodes without dropping item when replaced by a falling node
This commit is contained in:
parent
d9df592da8
commit
08f7ac5704
@ -79,18 +79,25 @@ core.register_entity(":__builtin:falling_node", {
|
|||||||
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
|
local np = {x=bcp.x, y=bcp.y+1, z=bcp.z}
|
||||||
-- Check what's here
|
-- Check what's here
|
||||||
local n2 = core.get_node(np)
|
local n2 = core.get_node(np)
|
||||||
-- remove node and replace it with it's drops
|
-- If it's not air or liquid, remove node and replace it with
|
||||||
local drops = core.get_node_drops(n2.name, "")
|
-- 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)
|
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
|
local _, dropped_item
|
||||||
for _, dropped_item in ipairs(drops) do
|
for _, dropped_item in ipairs(drops) do
|
||||||
core.add_item(np, dropped_item)
|
core.add_item(np, dropped_item)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
-- Run script hook
|
-- Run script hook
|
||||||
local _, callback
|
local _, callback
|
||||||
for _, callback in ipairs(core.registered_on_dignodes) do
|
for _, callback in ipairs(core.registered_on_dignodes) do
|
||||||
callback(np, n2, nil)
|
callback(np, n2, nil)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
-- Create node and remove entity
|
-- Create node and remove entity
|
||||||
core.add_node(np, self.node)
|
core.add_node(np, self.node)
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
Loading…
Reference in New Issue
Block a user