Merge pull request 'Don't drop dug banners in creative mode' (#3623) from banners into master

Reviewed-on: MineClone2/MineClone2#3623
Reviewed-by: PrairieWind <prairiewind@noreply.git.minetest.land>
This commit is contained in:
PrairieWind 2023-04-02 22:08:46 +00:00
commit 0f64fb79c5
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