Don't drop banners in creative mode

This commit is contained in:
MrRar 2023-04-02 12:19:39 -05:00 committed by Gitea
parent 0ee31bd322
commit 87bf3aed59

@ -113,6 +113,17 @@ local function on_dig_banner(pos, node, digger)
minetest.record_protection_violation(pos, name) minetest.record_protection_violation(pos, name)
return return
end end
local inv = minetest.get_meta(pos):get_inventory()
local item = inv:get_stack("banner", 1)
local item_str = item:is_empty() and "mcl_banners:banner_item_white"
or item:to_string()
minetest.handle_node_drops(pos, { item_str }, digger)
item:set_count(0)
inv:set_stack("banner", 1, item)
-- Remove node -- Remove node
minetest.remove_node(pos) minetest.remove_node(pos)
end end
@ -135,13 +146,12 @@ local function on_destruct_banner(pos, hanging)
v:remove() v:remove()
end end
end end
-- Drop item
local meta = minetest.get_meta(pos) -- Drop item only if it was not handled in on_dig_banner
local item = meta:get_inventory():get_stack("banner", 1) local inv = minetest.get_meta(pos):get_inventory()
local item = inv:get_stack("banner", 1)
if not item:is_empty() then if not item:is_empty() then
minetest.handle_node_drops(pos, {item:to_string()}) minetest.handle_node_drops(pos, {item:to_string()})
else
minetest.handle_node_drops(pos, {"mcl_banners:banner_item_white"})
end end
end end