Merge pull request 'Better fix for creative digging drops, and fix the itemframes LBM.' (#2915) from fix_itemdrops_and_itemframes into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2915
Reviewed-by: cora <cora@noreply.git.minetest.land>
This commit is contained in:
cora 2022-11-07 16:32:15 +00:00
commit bbd2ac904d
3 changed files with 24 additions and 34 deletions

View File

@ -213,8 +213,7 @@ minetest.register_on_punchnode(function(pos, node, puncher, pointed_thing)
if pointed_thing.type ~= "node" then return end if pointed_thing.type ~= "node" then return end
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
if def then if def then
if def.on_destruct then def.on_destruct(pos) end minetest.node_dig(pos,def,puncher)
minetest.dig_node(pos)
return true return true
end end
end) end)

View File

@ -14,11 +14,11 @@ mcl_itemframes.backwards_compatibility()
-- Define the standard frames. -- Define the standard frames.
mcl_itemframes.create_custom_frame("false", "item_frame", false, mcl_itemframes.create_custom_frame("false", "item_frame", false,
"mcl_itemframes_item_frame.png", mcl_colors.WHITE, "Item Frame", "mcl_itemframes_item_frame.png", mcl_colors.WHITE, "Can hold an item.",
"Can hold an item.","") "Item Frame", "")
mcl_itemframes.create_custom_frame("false", "glow_item_frame", true, mcl_itemframes.create_custom_frame("false", "glow_item_frame", true,
"mcl_itemframes_glow_item_frame.png", mcl_colors.WHITE, "Glowing Item Frame", "mcl_itemframes_glow_item_frame.png", mcl_colors.WHITE, "Can hold an item and glows.",
"Can hold an item and glows.","") "Glowing Item Frame", "")
-- Register the base frame's recipes. -- Register the base frame's recipes.
-- was going to make it a specialized function, but minetest refuses to play nice. -- was going to make it a specialized function, but minetest refuses to play nice.
@ -37,26 +37,4 @@ minetest.register_craft({
recipe = { 'mcl_mobitems:glow_ink_sac', 'mcl_itemframes:item_frame' }, recipe = { 'mcl_mobitems:glow_ink_sac', 'mcl_itemframes:item_frame' },
}) })
--[[ green frames just for testing mcl_itemframes.custom_register_lbm()
mcl_itemframes.create_custom_frame("false", "my_regular_frame", false,
"mcl_itemframes_item_frame.png", mcl_colors.DARK_GREEN, "A Green frame",
"My Green Frame")
mcl_itemframes.create_custom_frame("false", "my_glowing_frame", true,
"mcl_itemframes_glow_item_frame.png", mcl_colors.DARK_GREEN, "A Green glowing frame",
"My Green glowing Frame")
minetest.register_craft({
output = "mcl_itemframes:my_regular_frame",
recipe = {
{ "", "mcl_core:stick", "" },
{ "mcl_core:stick", "", "mcl_core:stick" },
{ "", "mcl_core:stick", "" },
}
})
minetest.register_craft({
type = "shapeless",
output = "mcl_itemframes:my_glowing_frame",
recipe = { "mcl_mobitems:glow_ink_sac", "mcl_itemframes:my_regular_frame" },
})
--]]

View File

@ -529,18 +529,30 @@ function mcl_itemframes.create_custom_frame(modname, name, has_glow, tiles, colo
minetest.register_node(":" .. working_name, custom_itemframe_definition) minetest.register_node(":" .. working_name, custom_itemframe_definition)
mcl_itemframes.update_frame_registry(modname, working_name, has_glow) mcl_itemframes.update_frame_registry(modname, working_name, has_glow)
mcl_itemframes.custom_register_lbm(working_name)
-- register Doc entry
if minetest.get_modpath("doc") then
doc.add_entry_alias("nodes", "mcl_itemframes:item_frame", "nodes", working_name)
end
end end
function mcl_itemframes.custom_register_lbm(name) function mcl_itemframes.custom_register_lbm()
local registered_frame_nodenames = {}
for i = 0, #mcl_itemframes.frames_registered.glowing do
table.insert(registered_frame_nodenames, mcl_itemframes.frames_registered.glowing[i])
end
for i = 0, #mcl_itemframes.frames_registered.standard do
table.insert(registered_frame_nodenames, mcl_itemframes.frames_registered.standard[i])
end
-- FIXME: Item entities can get destroyed by /clearobjects
-- glow frame
minetest.register_lbm({ minetest.register_lbm({
label = "Respawn item frame item entities", label = "Respawn item frame item entities",
name = "mcl_itemframes:respawn_entities", name = "mcl_itemframes:respawn_entities",
nodenames = { name }, nodenames = registered_frame_nodenames,
run_at_every_load = true, run_at_every_load = true,
action = function(pos, node) action = function(pos, node)
mcl_itemframes.update_item_entity(pos, node) mcl_itemframes.update_item_entity(pos, node)
@ -562,6 +574,7 @@ function mcl_itemframes.create_base_definitions()
mcl_itemframes.item_frame_base = { mcl_itemframes.item_frame_base = {
description = S("Item Frame"), description = S("Item Frame"),
name = "mcl_itemframes:item_frame",
_tt_help = S("Can hold an item"), _tt_help = S("Can hold an item"),
_doc_items_longdesc = S("Item frames are decorative blocks in which items can be placed."), _doc_items_longdesc = S("Item frames are decorative blocks in which items can be placed."),
_doc_items_usagehelp = S("Just place any item on the item frame. Use the item frame again to retrieve the item."), _doc_items_usagehelp = S("Just place any item on the item frame. Use the item frame again to retrieve the item."),