1
0
Fork 0

Don't drop banners in creative mode

cobble_abm_height
MrRar 2023-04-02 12:19:39 -05:00 committed by Gitea
parent 0ee31bd322
commit 87bf3aed59
1 changed files with 15 additions and 5 deletions

View File

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