From 95b142992228c0f84c830c9e32ba1f9a70921b18 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 30 Jan 2023 16:01:09 -0500 Subject: [PATCH 01/13] Add mcl_util to mcl_copper's mod.conf file. --- mods/ITEMS/mcl_copper/mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_copper/mod.conf b/mods/ITEMS/mcl_copper/mod.conf index dde96263ae..8cf5fd5798 100644 --- a/mods/ITEMS/mcl_copper/mod.conf +++ b/mods/ITEMS/mcl_copper/mod.conf @@ -1,4 +1,4 @@ name = mcl_copper author = NO11 -depends = mcl_core, mcl_sounds, mcl_stairs +depends = mcl_core, mcl_sounds, mcl_stairs, mcl_util description = Adds Copper Ore, blocks and items. From 8c703f1352b6356f1f5237db16bed2d78eea0b9d Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 30 Jan 2023 18:27:53 -0500 Subject: [PATCH 02/13] Refactored out "varient" in foavor of "variant". Set up a basic "on_place" function. Made _mcl_copper_waxed_variant and _mcl_copper_unwaxed_variant node parameters so that the waxing_copper_block and scraping_copper_block functions can be made generic. Adjusted said functions to look first for the variants, and added in protection checks for the blocks --- mods/ITEMS/mcl_copper/functions.lua | 115 ++++++++++++++++++++-------- mods/ITEMS/mcl_copper/nodes.lua | 29 +++++-- 2 files changed, 105 insertions(+), 39 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index 81dfdb69d8..348b9a9956 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -1,33 +1,84 @@ --local deepslate_mod = minetest.get_modpath("mcl_deepslate") +-- a basic on_place() +function mcl_copper.on_place (itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + local node = minetest.get_node(pointed_thing.under) + local pos = pointed_thing.under + local node_name = node.name + + if mcl_util.check_position_protection(pos, placer) then + return itemstack + end + + -- Use pointed node's on_rightclick function first, if present + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack then + return new_stack + end + + local placed = ItemStack(itemstack:get_name()) + if not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + minetest.item_place(placed, placer, pointed_thing, minetest.dir_to_facedir(vector.direction(pointed_thing.above, pointed_thing.under))) + + return itemstack + +end + local function register_oxidation_abm(abm_name, node_name, oxidized_variant) minetest.register_abm({ label = abm_name, - nodenames = {node_name}, + nodenames = { node_name }, interval = 500, chance = 3, action = function(pos, node) - minetest.swap_node(pos, {name = oxidized_variant, param2 = node.param2}) + minetest.swap_node(pos, { name = oxidized_variant, param2 = node.param2 }) end, }) end function waxing_copper_block(pos, node, player, itemstack, convert_to) if itemstack:get_name() == "mcl_honey:honeycomb" then - node.name = convert_to + -- prevent modification of protected nodes. + if mcl_util.check_position_protection(pos, player) then + return + end + + local def = minetest.registered_nodes(node.name) + + if def and def._mcl_copper_waxed_variant then + node.name = def._mcl_copper_waxed_variant + end + minetest.set_node(pos, node) awards.unlock(player:get_player_name(), "mcl:wax_on") if not minetest.is_creative_enabled(player:get_player_name()) then itemstack:take_item() end + return itemstack + else - return true + return -- changed to work with mcl_util.call_on_rightclick() end end function scraping_copper_block(pos, node, player, itemstack, convert_to) if itemstack:get_name():find("axe") then - node.name = convert_to + -- prevent modification of protected nodes. + if mcl_util.check_position_protection(pos, player) then + return + end + + local def = minetest.registered_nodes(node.name) + + if def and def._mcl_copper_unwaxed_variant then + node.name = def._mcl_copper_unwaxed_variant + end + minetest.set_node(pos, node) awards.unlock(player:get_player_name(), "mcl:wax_off") if not minetest.is_creative_enabled(player:get_player_name()) then @@ -36,7 +87,7 @@ function scraping_copper_block(pos, node, player, itemstack, convert_to) itemstack:add_wear(wear) end else - return true + return end end @@ -164,41 +215,41 @@ if not deepslate_mod then end --]] local block_oxidation = { - {"", "_exposed"}, - {"_cut", "_exposed_cut"}, - {"_exposed", "_weathered"}, - {"_exposed_cut", "_weathered_cut"}, - {"_weathered", "_oxidized"}, - {"_weathered_cut", "_oxidized_cut"} + { "", "_exposed" }, + { "_cut", "_exposed_cut" }, + { "_exposed", "_weathered" }, + { "_exposed_cut", "_weathered_cut" }, + { "_weathered", "_oxidized" }, + { "_weathered_cut", "_oxidized_cut" } } local stair_oxidation = { - {"slab", "cut", "exposed_cut"}, - {"slab", "exposed_cut", "weathered_cut"}, - {"slab", "weathered_cut", "oxidized_cut"}, - {"slab", "cut_top", "exposed_cut_top"}, - {"slab", "exposed_cut_top", "weathered_cut_top"}, - {"slab", "weathered_cut_top", "oxidized_cut_double"}, - {"slab", "cut_double", "exposed_cut_double"}, - {"slab", "exposed_cut_double", "weathered_cut_double"}, - {"slab", "weathered_cut_double", "oxidized_cut_double"}, - {"stair", "cut", "exposed_cut"}, - {"stair", "exposed_cut", "weathered_cut"}, - {"stair", "weathered_cut", "oxidized_cut"}, - {"stair", "cut_inner", "exposed_cut_inner"}, - {"stair", "exposed_cut_inner", "weathered_cut_inner"}, - {"stair", "weathered_cut_inner", "oxidized_cut_inner"}, - {"stair", "cut_outer", "exposed_cut_outer"}, - {"stair", "exposed_cut_outer", "weathered_cut_outer"}, - {"stair", "weathered_cut_outer", "oxidized_cut_outer"} + { "slab", "cut", "exposed_cut" }, + { "slab", "exposed_cut", "weathered_cut" }, + { "slab", "weathered_cut", "oxidized_cut" }, + { "slab", "cut_top", "exposed_cut_top" }, + { "slab", "exposed_cut_top", "weathered_cut_top" }, + { "slab", "weathered_cut_top", "oxidized_cut_double" }, + { "slab", "cut_double", "exposed_cut_double" }, + { "slab", "exposed_cut_double", "weathered_cut_double" }, + { "slab", "weathered_cut_double", "oxidized_cut_double" }, + { "stair", "cut", "exposed_cut" }, + { "stair", "exposed_cut", "weathered_cut" }, + { "stair", "weathered_cut", "oxidized_cut" }, + { "stair", "cut_inner", "exposed_cut_inner" }, + { "stair", "exposed_cut_inner", "weathered_cut_inner" }, + { "stair", "weathered_cut_inner", "oxidized_cut_inner" }, + { "stair", "cut_outer", "exposed_cut_outer" }, + { "stair", "exposed_cut_outer", "weathered_cut_outer" }, + { "stair", "weathered_cut_outer", "oxidized_cut_outer" } } for _, b in pairs(block_oxidation) do - register_oxidation_abm("Copper oxidation", "mcl_copper:block"..b[1], "mcl_copper:block"..b[2]) + register_oxidation_abm("Copper oxidation", "mcl_copper:block" .. b[1], "mcl_copper:block" .. b[2]) end for _, s in pairs(stair_oxidation) do - register_oxidation_abm("Copper oxidation", "mcl_stairs:"..s[1].."_copper_"..s[2], "mcl_stairs:"..s[1].."_copper_"..s[3]) + register_oxidation_abm("Copper oxidation", "mcl_stairs:" .. s[1] .. "_copper_" .. s[2], "mcl_stairs:" .. s[1] .. "_copper_" .. s[3]) end --local axes = {"wood", "stone", "iron", "gold", "diamond"} diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index 6c498f9f68..ecc80a0f26 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -12,7 +12,6 @@ minetest.register_node("mcl_copper:stone_with_copper", { _mcl_hardness = 3, _mcl_silk_touch_drop = true, _mcl_fortune_drop = mcl_core.fortune_drop_ore, - }) minetest.register_node("mcl_copper:block_raw", { @@ -35,6 +34,7 @@ minetest.register_node("mcl_copper:block", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 3, + _mcl_copper_waxed_variant = "mcl_copper:waxed_block", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") end, }) @@ -47,6 +47,7 @@ minetest.register_node("mcl_copper:waxed_block", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 3, + _mcl_copper_unwaxed_variant = "mcl_copper:block", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) @@ -59,7 +60,8 @@ minetest.register_node("mcl_copper:block_exposed", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block", + _mcl_anti_oxidation_variant = "mcl_copper:block", + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end, }) @@ -72,6 +74,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) @@ -84,7 +87,8 @@ minetest.register_node("mcl_copper:block_weathered", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_exposed", + _mcl_anti_oxidation_variant = "mcl_copper:block_exposed", + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end, }) @@ -97,6 +101,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end, }) @@ -109,7 +114,8 @@ minetest.register_node("mcl_copper:block_oxidized", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_weathered", + _mcl_anti_oxidation_variant = "mcl_copper:block_weathered", + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end, }) @@ -122,6 +128,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end, }) @@ -134,6 +141,7 @@ minetest.register_node("mcl_copper:block_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end, }) @@ -146,6 +154,7 @@ minetest.register_node("mcl_copper:waxed_block_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) @@ -158,7 +167,8 @@ minetest.register_node("mcl_copper:block_exposed_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_cut", + _mcl_anti_oxidation_variant = "mcl_copper:block_cut", + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end, }) @@ -171,6 +181,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) @@ -183,7 +194,8 @@ minetest.register_node("mcl_copper:block_weathered_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_exposed_cut", + _mcl_anti_oxidation_variant = "mcl_copper:block_exposed_cut", + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end, }) @@ -196,6 +208,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed_cut", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end, }) @@ -208,7 +221,8 @@ minetest.register_node("mcl_copper:block_oxidized_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_varient = "mcl_copper:block_weathered_cut", + _mcl_anti_oxidation_variant = "mcl_copper:block_weathered_cut", + _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end, }) @@ -221,6 +235,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, + _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered_cut", on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end, }) From 319602508df7b3e277003d2731e4133340cfc9ef Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 30 Jan 2023 20:13:32 -0500 Subject: [PATCH 03/13] Make copper block nodes use on_place. --- mods/ITEMS/mcl_copper/nodes.lua | 50 ++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index ecc80a0f26..9e1a4f4a85 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -35,7 +35,10 @@ minetest.register_node("mcl_copper:block", { _mcl_blast_resistance = 6, _mcl_hardness = 3, _mcl_copper_waxed_variant = "mcl_copper:waxed_block", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) + return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") + end, }) minetest.register_node("mcl_copper:waxed_block", { @@ -48,7 +51,8 @@ minetest.register_node("mcl_copper:waxed_block", { _mcl_blast_resistance = 6, _mcl_hardness = 3, _mcl_copper_unwaxed_variant = "mcl_copper:block", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) minetest.register_node("mcl_copper:block_exposed", { @@ -62,7 +66,8 @@ minetest.register_node("mcl_copper:block_exposed", { _mcl_hardness = 5, _mcl_anti_oxidation_variant = "mcl_copper:block", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end, }) minetest.register_node("mcl_copper:waxed_block_exposed", { @@ -75,7 +80,8 @@ minetest.register_node("mcl_copper:waxed_block_exposed", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) minetest.register_node("mcl_copper:block_weathered", { @@ -89,7 +95,8 @@ minetest.register_node("mcl_copper:block_weathered", { _mcl_hardness = 5, _mcl_anti_oxidation_variant = "mcl_copper:block_exposed", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end, }) minetest.register_node("mcl_copper:waxed_block_weathered", { @@ -102,7 +109,8 @@ minetest.register_node("mcl_copper:waxed_block_weathered", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end, }) minetest.register_node("mcl_copper:block_oxidized", { @@ -116,7 +124,8 @@ minetest.register_node("mcl_copper:block_oxidized", { _mcl_hardness = 5, _mcl_anti_oxidation_variant = "mcl_copper:block_weathered", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end, }) minetest.register_node("mcl_copper:waxed_block_oxidized", { @@ -129,7 +138,8 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end, }) minetest.register_node("mcl_copper:block_cut", { @@ -142,7 +152,8 @@ minetest.register_node("mcl_copper:block_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end, }) minetest.register_node("mcl_copper:waxed_block_cut", { @@ -155,7 +166,8 @@ minetest.register_node("mcl_copper:waxed_block_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) minetest.register_node("mcl_copper:block_exposed_cut", { @@ -169,7 +181,8 @@ minetest.register_node("mcl_copper:block_exposed_cut", { _mcl_hardness = 5, _mcl_anti_oxidation_variant = "mcl_copper:block_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end, }) minetest.register_node("mcl_copper:waxed_block_exposed_cut", { @@ -182,7 +195,8 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) minetest.register_node("mcl_copper:block_weathered_cut", { @@ -196,7 +210,8 @@ minetest.register_node("mcl_copper:block_weathered_cut", { _mcl_hardness = 5, _mcl_anti_oxidation_variant = "mcl_copper:block_exposed_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end, }) minetest.register_node("mcl_copper:waxed_block_weathered_cut", { @@ -209,7 +224,8 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed_cut", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end, }) minetest.register_node("mcl_copper:block_oxidized_cut", { @@ -223,7 +239,8 @@ minetest.register_node("mcl_copper:block_oxidized_cut", { _mcl_hardness = 5, _mcl_anti_oxidation_variant = "mcl_copper:block_weathered_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", - on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end, }) minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { @@ -236,7 +253,8 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered_cut", - on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end, + on_place = mcl_copper.on_place, + on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end, }) mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut", From d04f162d8fe074d69f14f565ef4535bfcedac01c Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 30 Jan 2023 23:53:40 -0500 Subject: [PATCH 04/13] Initialize Global variable. --- mods/ITEMS/mcl_copper/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ITEMS/mcl_copper/init.lua b/mods/ITEMS/mcl_copper/init.lua index a99d03f2cc..937d262e2c 100644 --- a/mods/ITEMS/mcl_copper/init.lua +++ b/mods/ITEMS/mcl_copper/init.lua @@ -1,5 +1,7 @@ local path = minetest.get_modpath("mcl_copper") +mcl_copper = {} -- initialize global variable. + dofile(path .. "/functions.lua") dofile(path .. "/nodes.lua") dofile(path .. "/items.lua") From 425cf53194654cdc174282de623e99cd9659fa42 Mon Sep 17 00:00:00 2001 From: Michieal Date: Mon, 30 Jan 2023 23:57:50 -0500 Subject: [PATCH 05/13] fix minor bug. --- mods/ITEMS/mcl_copper/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index 348b9a9956..fda6a24d15 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -48,7 +48,7 @@ function waxing_copper_block(pos, node, player, itemstack, convert_to) return end - local def = minetest.registered_nodes(node.name) + local def = minetest.registered_nodes[node.name] if def and def._mcl_copper_waxed_variant then node.name = def._mcl_copper_waxed_variant @@ -73,7 +73,7 @@ function scraping_copper_block(pos, node, player, itemstack, convert_to) return end - local def = minetest.registered_nodes(node.name) + local def = minetest.registered_nodes[node.name] if def and def._mcl_copper_unwaxed_variant then node.name = def._mcl_copper_unwaxed_variant From 5b1c7f2d3a08b8e3f5d3926c60c726789e79b798 Mon Sep 17 00:00:00 2001 From: Michieal Date: Wed, 1 Feb 2023 18:39:13 -0500 Subject: [PATCH 06/13] Everything *BUT* scraping works properly. --- mods/ITEMS/mcl_copper/functions.lua | 21 +++++++++++++++++---- mods/ITEMS/mcl_copper/nodes.lua | 18 ------------------ mods/ITEMS/mcl_honey/init.lua | 17 +++++++++++++++++ mods/ITEMS/mcl_honey/mod.conf | 1 + 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index fda6a24d15..1b861f5cd1 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -13,6 +13,20 @@ function mcl_copper.on_place (itemstack, placer, pointed_thing) return itemstack end + -- Apply scraping with an axe. (string.find returns nil if the string is not found.) + local wield_item = placer:get_wielded_item() + if string.find (wield_item:get_name(), "tools:axe" ) ~= nil then + if string.find(node_name, "mcl_copper") ~= nil then + if string.find(node_name, "waxed") ~= nil then + local item = mcl_copper.scraping_copper_block(pos, node, placer, wield_item) + if item and item:get_name() ~= "" then + placer:set_wielded_item(item) -- add wear to the axe. + return + end + end + end + end + -- Use pointed node's on_rightclick function first, if present local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) if new_stack then @@ -26,7 +40,6 @@ function mcl_copper.on_place (itemstack, placer, pointed_thing) minetest.item_place(placed, placer, pointed_thing, minetest.dir_to_facedir(vector.direction(pointed_thing.above, pointed_thing.under))) return itemstack - end local function register_oxidation_abm(abm_name, node_name, oxidized_variant) @@ -41,7 +54,7 @@ local function register_oxidation_abm(abm_name, node_name, oxidized_variant) }) end -function waxing_copper_block(pos, node, player, itemstack, convert_to) +function mcl_copper.waxing_copper_block(pos, node, player, itemstack) if itemstack:get_name() == "mcl_honey:honeycomb" then -- prevent modification of protected nodes. if mcl_util.check_position_protection(pos, player) then @@ -60,13 +73,12 @@ function waxing_copper_block(pos, node, player, itemstack, convert_to) itemstack:take_item() end return itemstack - else return -- changed to work with mcl_util.call_on_rightclick() end end -function scraping_copper_block(pos, node, player, itemstack, convert_to) +function mcl_copper.scraping_copper_block(pos, node, player, itemstack) if itemstack:get_name():find("axe") then -- prevent modification of protected nodes. if mcl_util.check_position_protection(pos, player) then @@ -85,6 +97,7 @@ function scraping_copper_block(pos, node, player, itemstack, convert_to) local tool = itemstack:get_name() local wear = mcl_autogroup.get_wear(tool, "axey") itemstack:add_wear(wear) + return itemstack end else return diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index 9e1a4f4a85..2ef6c9e4d9 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -36,9 +36,6 @@ minetest.register_node("mcl_copper:block", { _mcl_hardness = 3, _mcl_copper_waxed_variant = "mcl_copper:waxed_block", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) - return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") - end, }) minetest.register_node("mcl_copper:waxed_block", { @@ -52,7 +49,6 @@ minetest.register_node("mcl_copper:waxed_block", { _mcl_hardness = 3, _mcl_copper_unwaxed_variant = "mcl_copper:block", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) minetest.register_node("mcl_copper:block_exposed", { @@ -67,7 +63,6 @@ minetest.register_node("mcl_copper:block_exposed", { _mcl_anti_oxidation_variant = "mcl_copper:block", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end, }) minetest.register_node("mcl_copper:waxed_block_exposed", { @@ -81,7 +76,6 @@ minetest.register_node("mcl_copper:waxed_block_exposed", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end, }) minetest.register_node("mcl_copper:block_weathered", { @@ -96,7 +90,6 @@ minetest.register_node("mcl_copper:block_weathered", { _mcl_anti_oxidation_variant = "mcl_copper:block_exposed", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end, }) minetest.register_node("mcl_copper:waxed_block_weathered", { @@ -110,7 +103,6 @@ minetest.register_node("mcl_copper:waxed_block_weathered", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end, }) minetest.register_node("mcl_copper:block_oxidized", { @@ -125,7 +117,6 @@ minetest.register_node("mcl_copper:block_oxidized", { _mcl_anti_oxidation_variant = "mcl_copper:block_weathered", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end, }) minetest.register_node("mcl_copper:waxed_block_oxidized", { @@ -139,7 +130,6 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end, }) minetest.register_node("mcl_copper:block_cut", { @@ -153,7 +143,6 @@ minetest.register_node("mcl_copper:block_cut", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end, }) minetest.register_node("mcl_copper:waxed_block_cut", { @@ -167,7 +156,6 @@ minetest.register_node("mcl_copper:waxed_block_cut", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) minetest.register_node("mcl_copper:block_exposed_cut", { @@ -182,7 +170,6 @@ minetest.register_node("mcl_copper:block_exposed_cut", { _mcl_anti_oxidation_variant = "mcl_copper:block_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end, }) minetest.register_node("mcl_copper:waxed_block_exposed_cut", { @@ -196,7 +183,6 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end, }) minetest.register_node("mcl_copper:block_weathered_cut", { @@ -211,7 +197,6 @@ minetest.register_node("mcl_copper:block_weathered_cut", { _mcl_anti_oxidation_variant = "mcl_copper:block_exposed_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end, }) minetest.register_node("mcl_copper:waxed_block_weathered_cut", { @@ -225,7 +210,6 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end, }) minetest.register_node("mcl_copper:block_oxidized_cut", { @@ -240,7 +224,6 @@ minetest.register_node("mcl_copper:block_oxidized_cut", { _mcl_anti_oxidation_variant = "mcl_copper:block_weathered_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end, }) minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { @@ -254,7 +237,6 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { _mcl_hardness = 5, _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered_cut", on_place = mcl_copper.on_place, - on_rightclick = function(pos, node, player, itemstack) return scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end, }) mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut", diff --git a/mods/ITEMS/mcl_honey/init.lua b/mods/ITEMS/mcl_honey/init.lua index 82e3d09954..7fbd0d3229 100644 --- a/mods/ITEMS/mcl_honey/init.lua +++ b/mods/ITEMS/mcl_honey/init.lua @@ -13,6 +13,23 @@ minetest.register_craftitem("mcl_honey:honeycomb", { _doc_items_usagehelp = S("Use on copper blocks to prevent further oxidation."), inventory_image = "mcl_honey_honeycomb.png", groups = { craftitem = 1 }, + on_place = function(itemstack, placer, pointed_thing) + if pointed_thing.type ~= "node" then + return itemstack + end + local node = minetest.get_node(pointed_thing.under) + local pos = pointed_thing.under + local node_name = node.name + + if minetest.get_modpath("mcl_copper") and mcl_copper then + if string.find(node_name,"mcl_copper") ~= nil then + if string.find(node_name,"waxed") == nil then + -- wax the copper block. + return mcl_copper.waxing_copper_block(pos, node, placer, itemstack) + end + end + end + end, }) minetest.register_node("mcl_honey:honeycomb_block", { diff --git a/mods/ITEMS/mcl_honey/mod.conf b/mods/ITEMS/mcl_honey/mod.conf index 4368112911..ff211cefa1 100644 --- a/mods/ITEMS/mcl_honey/mod.conf +++ b/mods/ITEMS/mcl_honey/mod.conf @@ -2,3 +2,4 @@ name = mcl_honey author = PrairieWind description = MineClone 2 mod that adds honey and honeycomb and the respective block versions. depends = mesecons_mvps +optional = mcl_copper From 4b0b3217e233b1b4f5c1a4a5137fc49828cb1f93 Mon Sep 17 00:00:00 2001 From: Michieal Date: Wed, 1 Feb 2023 19:55:23 -0500 Subject: [PATCH 07/13] added in TODO --- mods/ITEMS/mcl_copper/nodes.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index 2ef6c9e4d9..e5bc047f71 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -350,3 +350,5 @@ mcl_stairs.register_stair("waxed_copper_oxidized_cut", "mcl_copper:waxed_block_o S("Waxed Stairs of Oxidized Cut Copper"), nil, 6, nil, "woodlike") + +-- TODO: Make stairs and slabs be waxable / scrapable. From b771f314feb78e6c296d245e42622feea673d1c7 Mon Sep 17 00:00:00 2001 From: Michieal Date: Wed, 1 Feb 2023 23:24:59 -0500 Subject: [PATCH 08/13] Removed "scraping_copper_block" function. Fixed the wax copper blocks variants to have the wax removed. --- mods/ITEMS/mcl_copper/functions.lua | 40 ----------------------------- mods/ITEMS/mcl_copper/nodes.lua | 16 ++++++------ 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index 1b861f5cd1..ccb3742146 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -13,20 +13,6 @@ function mcl_copper.on_place (itemstack, placer, pointed_thing) return itemstack end - -- Apply scraping with an axe. (string.find returns nil if the string is not found.) - local wield_item = placer:get_wielded_item() - if string.find (wield_item:get_name(), "tools:axe" ) ~= nil then - if string.find(node_name, "mcl_copper") ~= nil then - if string.find(node_name, "waxed") ~= nil then - local item = mcl_copper.scraping_copper_block(pos, node, placer, wield_item) - if item and item:get_name() ~= "" then - placer:set_wielded_item(item) -- add wear to the axe. - return - end - end - end - end - -- Use pointed node's on_rightclick function first, if present local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) if new_stack then @@ -78,32 +64,6 @@ function mcl_copper.waxing_copper_block(pos, node, player, itemstack) end end -function mcl_copper.scraping_copper_block(pos, node, player, itemstack) - if itemstack:get_name():find("axe") then - -- prevent modification of protected nodes. - if mcl_util.check_position_protection(pos, player) then - return - end - - local def = minetest.registered_nodes[node.name] - - if def and def._mcl_copper_unwaxed_variant then - node.name = def._mcl_copper_unwaxed_variant - end - - minetest.set_node(pos, node) - awards.unlock(player:get_player_name(), "mcl:wax_off") - if not minetest.is_creative_enabled(player:get_player_name()) then - local tool = itemstack:get_name() - local wear = mcl_autogroup.get_wear(tool, "axey") - itemstack:add_wear(wear) - return itemstack - end - else - return - end -end - --[[ local stairs = { {"stair", "exposed", "_inner", "cut_inner"}, diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index e5bc047f71..f581eb4169 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -47,7 +47,7 @@ minetest.register_node("mcl_copper:waxed_block", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 3, - _mcl_copper_unwaxed_variant = "mcl_copper:block", + _mcl_stripped_variant = "mcl_copper:block", on_place = mcl_copper.on_place, }) @@ -74,7 +74,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block", + _mcl_stripped_variant = "mcl_copper:block", on_place = mcl_copper.on_place, }) @@ -101,7 +101,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed", + _mcl_stripped_variant = "mcl_copper:block_exposed", on_place = mcl_copper.on_place, }) @@ -128,7 +128,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered", + _mcl_stripped_variant = "mcl_copper:block_weathered", on_place = mcl_copper.on_place, }) @@ -154,7 +154,7 @@ minetest.register_node("mcl_copper:waxed_block_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", + _mcl_stripped_variant = "mcl_copper:block_cut", on_place = mcl_copper.on_place, }) @@ -181,7 +181,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block_cut", + _mcl_stripped_variant = "mcl_copper:block_cut", on_place = mcl_copper.on_place, }) @@ -208,7 +208,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block_exposed_cut", + _mcl_stripped_variant = "mcl_copper:block_exposed_cut", on_place = mcl_copper.on_place, }) @@ -235,7 +235,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_copper_unwaxed_variant = "mcl_copper:block_weathered_cut", + _mcl_stripped_variant = "mcl_copper:block_weathered_cut", on_place = mcl_copper.on_place, }) From c370f1884bfdfe9f5a3a59bfb9d4271c3f7dc101 Mon Sep 17 00:00:00 2001 From: Michieal Date: Wed, 1 Feb 2023 23:34:02 -0500 Subject: [PATCH 09/13] Fixed the unwax copper blocks variants to be able to properly remove oxidization levels properly. MCL_COPPER Blocks off all types (not stairs and slabs) now function properly. --- mods/ITEMS/mcl_copper/nodes.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index f581eb4169..c0246de41e 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -60,8 +60,8 @@ minetest.register_node("mcl_copper:block_exposed", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_variant = "mcl_copper:block", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", + _mcl_stripped_variant = "mcl_copper:block", on_place = mcl_copper.on_place, }) @@ -87,8 +87,8 @@ minetest.register_node("mcl_copper:block_weathered", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_variant = "mcl_copper:block_exposed", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", + _mcl_stripped_variant = "mcl_copper:block_exposed", on_place = mcl_copper.on_place, }) @@ -114,8 +114,8 @@ minetest.register_node("mcl_copper:block_oxidized", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_variant = "mcl_copper:block_weathered", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", + _mcl_stripped_variant = "mcl_copper:block_weathered", on_place = mcl_copper.on_place, }) @@ -167,8 +167,8 @@ minetest.register_node("mcl_copper:block_exposed_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_variant = "mcl_copper:block_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", + _mcl_stripped_variant = "mcl_copper:block_cut", on_place = mcl_copper.on_place, }) @@ -194,7 +194,7 @@ minetest.register_node("mcl_copper:block_weathered_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_variant = "mcl_copper:block_exposed_cut", + _mcl_stripped_variant = "mcl_copper:block_exposed_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", on_place = mcl_copper.on_place, }) @@ -221,7 +221,7 @@ minetest.register_node("mcl_copper:block_oxidized_cut", { sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 6, _mcl_hardness = 5, - _mcl_anti_oxidation_variant = "mcl_copper:block_weathered_cut", + _mcl_stripped_variant = "mcl_copper:block_weathered_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", on_place = mcl_copper.on_place, }) From a3bc3fd9b9503fd7a3b176d2382f91d96d4120d0 Mon Sep 17 00:00:00 2001 From: Michieal Date: Wed, 1 Feb 2023 23:49:04 -0500 Subject: [PATCH 10/13] Removed old commented code to prevent accidental re-enabling, and put the todo into the correct spot. --- mods/ITEMS/mcl_copper/functions.lua | 108 +--------------------------- mods/ITEMS/mcl_copper/nodes.lua | 2 - 2 files changed, 1 insertion(+), 109 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index ccb3742146..c7cdb64720 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -86,107 +86,6 @@ local stairs = { {"stair", "weathered", "", "exposed_cut"}, }]] ---[[ -local function anti_oxidation_particles(pointed_thing) - local pos = pointed_thing.under - minetest.add_particlespawner({ - amount = 8, - time = 1, - minpos = {x = pos.x - 1, y = pos.y - 1, z = pos.z - 1}, - maxpos = {x = pos.x + 1, y = pos.y + 1, z = pos.z + 1}, - minvel = {x = 0, y = 0, z = 0}, - maxvel = {x = 0, y = 0, z = 0}, - minacc = {x = 0, y = 0, z = 0}, - maxacc = {x = 0, y = 0, z = 0}, - minexptime = 0.5, - maxexptime = 1, - minsize = 1, - maxsize = 2.5, - collisiondetection = false, - vertical = false, - texture = "mcl_copper_anti_oxidation_particle.png", - glow = 5, - }) -end - -local function add_wear(placer, itemstack) - if not minetest.is_creative_enabled(placer:get_player_name()) then - local tool = itemstack:get_name() - local wear = mcl_autogroup.get_wear(tool, "axey") - itemstack:add_wear(wear) - end -end - -local function anti_oxidation(itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then return end - - local node = minetest.get_node(pointed_thing.under) - local noddef = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name] - - if not placer:get_player_control().sneak and noddef.on_rightclick then - return minetest.item_place(itemstack, placer, pointed_thing) - end - - if minetest.is_protected(pointed_thing.under, placer:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, placer:get_player_name()) - return itemstack - end - - if noddef._mcl_stripped_variant == nil then - for _, c in pairs(stairs) do - if noddef.name == "mcl_stairs:"..c[1].."_copper_"..c[2].."_cut"..c[3] then - minetest.swap_node(pointed_thing.under, {name="mcl_stairs:"..c[1].."_copper_"..c[4], param2=node.param2}) - anti_oxidation_particles(pointed_thing) - add_wear(placer, itemstack) - end - end - if noddef._mcl_anti_oxidation_variant ~= nil then - minetest.swap_node(pointed_thing.under, {name=noddef._mcl_anti_oxidation_variant, param2=node.param2}) - anti_oxidation_particles(pointed_thing) - add_wear(placer, itemstack) - end - elseif noddef._mcl_stripped_variant ~= nil then - minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_variant, param2=node.param2}) - add_wear(placer, itemstack) - else - return itemstack - end - return itemstack -end - -local function register_axe_override(axe_name) - minetest.override_item("mcl_tools:axe_"..axe_name, { - on_place = anti_oxidation, - }) -end]] - ---[[ Commented out for now because there the discussion how to handle this is ongoing -local stonelike = {"mcl_core:stone", "mcl_core:diorite", "mcl_core:andesite", "mcl_core:granite"} -if not deepslate_mod then - if minetest.settings:get_bool("mcl_generate_ores", true) then - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_copper:stone_with_copper", - wherein = stonelike, - clust_scarcity = 830, - clust_num_ores = 5, - clust_size = 3, - y_min = mcl_vars.mg_overworld_min, - y_max = mcl_worlds.layer_to_y(39), - }) - minetest.register_ore({ - ore_type = "scatter", - ore = "mcl_copper:stone_with_copper", - wherein = stonelike, - clust_scarcity = 1660, - clust_num_ores = 4, - clust_size = 2, - y_min = mcl_worlds.layer_to_y(40), - y_max = mcl_worlds.layer_to_y(63), - }) - end -end ---]] local block_oxidation = { { "", "_exposed" }, { "_cut", "_exposed_cut" }, @@ -223,11 +122,6 @@ end for _, s in pairs(stair_oxidation) do register_oxidation_abm("Copper oxidation", "mcl_stairs:" .. s[1] .. "_copper_" .. s[2], "mcl_stairs:" .. s[1] .. "_copper_" .. s[3]) + -- TODO: Make stairs and slabs be waxable / scrapable. Place the Node overrides here, just like they are on the copper nodes, and it will work properly. May need to update mcl_honey to call the waxing function for stairs and slabs. end ---local axes = {"wood", "stone", "iron", "gold", "diamond"} ---[[ -for _, axe in pairs(axes) do - register_axe_override(axe) -end -]] diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index c0246de41e..ca3f563cf1 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -350,5 +350,3 @@ mcl_stairs.register_stair("waxed_copper_oxidized_cut", "mcl_copper:waxed_block_o S("Waxed Stairs of Oxidized Cut Copper"), nil, 6, nil, "woodlike") - --- TODO: Make stairs and slabs be waxable / scrapable. From 50effaa807c350ff9a4dc9d6ff40bdd3e3ac159d Mon Sep 17 00:00:00 2001 From: Michieal Date: Fri, 3 Feb 2023 14:09:16 -0500 Subject: [PATCH 11/13] Made Requested changes from Pull Request. --- mods/ITEMS/mcl_copper/functions.lua | 39 +++++++++++++---------------- mods/ITEMS/mcl_copper/nodes.lua | 32 +++++++++++------------ mods/ITEMS/mcl_honey/init.lua | 36 +++++++++++++------------- 3 files changed, 52 insertions(+), 55 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index c7cdb64720..2edb79b946 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -1,6 +1,6 @@ --local deepslate_mod = minetest.get_modpath("mcl_deepslate") --- a basic on_place() +--[[ a basic on_place() function mcl_copper.on_place (itemstack, placer, pointed_thing) if pointed_thing.type ~= "node" then return itemstack @@ -27,6 +27,7 @@ function mcl_copper.on_place (itemstack, placer, pointed_thing) return itemstack end +--]] local function register_oxidation_abm(abm_name, node_name, oxidized_variant) minetest.register_abm({ @@ -41,27 +42,23 @@ local function register_oxidation_abm(abm_name, node_name, oxidized_variant) end function mcl_copper.waxing_copper_block(pos, node, player, itemstack) - if itemstack:get_name() == "mcl_honey:honeycomb" then - -- prevent modification of protected nodes. - if mcl_util.check_position_protection(pos, player) then - return - end - - local def = minetest.registered_nodes[node.name] - - if def and def._mcl_copper_waxed_variant then - node.name = def._mcl_copper_waxed_variant - end - - minetest.set_node(pos, node) - awards.unlock(player:get_player_name(), "mcl:wax_on") - if not minetest.is_creative_enabled(player:get_player_name()) then - itemstack:take_item() - end - return itemstack - else - return -- changed to work with mcl_util.call_on_rightclick() + -- prevent modification of protected nodes. + if mcl_util.check_position_protection(pos, player) then + return end + + local def = minetest.registered_nodes[node.name] + + if def and def._mcl_copper_waxed_variant then + node.name = def._mcl_copper_waxed_variant + end + + minetest.set_node(pos, node) + awards.unlock(player:get_player_name(), "mcl:wax_on") + if not minetest.is_creative_enabled(player:get_player_name()) then + itemstack:take_item() + end + return itemstack end --[[ diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index ca3f563cf1..15a5a0fd7e 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -35,7 +35,7 @@ minetest.register_node("mcl_copper:block", { _mcl_blast_resistance = 6, _mcl_hardness = 3, _mcl_copper_waxed_variant = "mcl_copper:waxed_block", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block", { @@ -48,7 +48,7 @@ minetest.register_node("mcl_copper:waxed_block", { _mcl_blast_resistance = 6, _mcl_hardness = 3, _mcl_stripped_variant = "mcl_copper:block", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_exposed", { @@ -62,7 +62,7 @@ minetest.register_node("mcl_copper:block_exposed", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", _mcl_stripped_variant = "mcl_copper:block", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_exposed", { @@ -75,7 +75,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_weathered", { @@ -89,7 +89,7 @@ minetest.register_node("mcl_copper:block_weathered", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", _mcl_stripped_variant = "mcl_copper:block_exposed", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_weathered", { @@ -102,7 +102,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_oxidized", { @@ -116,7 +116,7 @@ minetest.register_node("mcl_copper:block_oxidized", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", _mcl_stripped_variant = "mcl_copper:block_weathered", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_oxidized", { @@ -129,7 +129,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_weathered", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_cut", { @@ -142,7 +142,7 @@ minetest.register_node("mcl_copper:block_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_cut", { @@ -155,7 +155,7 @@ minetest.register_node("mcl_copper:waxed_block_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_exposed_cut", { @@ -169,7 +169,7 @@ minetest.register_node("mcl_copper:block_exposed_cut", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", _mcl_stripped_variant = "mcl_copper:block_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_exposed_cut", { @@ -182,7 +182,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_weathered_cut", { @@ -196,7 +196,7 @@ minetest.register_node("mcl_copper:block_weathered_cut", { _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_weathered_cut", { @@ -209,7 +209,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_oxidized_cut", { @@ -223,7 +223,7 @@ minetest.register_node("mcl_copper:block_oxidized_cut", { _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_weathered_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { @@ -236,7 +236,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_weathered_cut", - on_place = mcl_copper.on_place, + --on_place = mcl_copper.on_place, }) mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut", diff --git a/mods/ITEMS/mcl_honey/init.lua b/mods/ITEMS/mcl_honey/init.lua index 7fbd0d3229..e7f0a5adf3 100644 --- a/mods/ITEMS/mcl_honey/init.lua +++ b/mods/ITEMS/mcl_honey/init.lua @@ -4,7 +4,7 @@ -- Variables local S = minetest.get_translator(minetest.get_current_modname()) -local alldirs = {{x=0,y=0,z=1}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=-1,y=0,z=0}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}} +local alldirs = { { x = 0, y = 0, z = 1 }, { x = 1, y = 0, z = 0 }, { x = 0, y = 0, z = -1 }, { x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }, { x = 0, y = 1, z = 0 } } -- Honeycomb minetest.register_craftitem("mcl_honey:honeycomb", { @@ -22,11 +22,11 @@ minetest.register_craftitem("mcl_honey:honeycomb", { local node_name = node.name if minetest.get_modpath("mcl_copper") and mcl_copper then - if string.find(node_name,"mcl_copper") ~= nil then - if string.find(node_name,"waxed") == nil then - -- wax the copper block. - return mcl_copper.waxing_copper_block(pos, node, placer, itemstack) - end + local def = minetest.registered_nodes[node_name] + + if def and def._mcl_copper_waxed_variant then + -- wax the copper block. + return mcl_copper.waxing_copper_block(pos, node, placer, itemstack) end end end, @@ -40,10 +40,10 @@ minetest.register_node("mcl_honey:honeycomb_block", { }, groups = { handy = 1, deco_block = 1 }, sounds = { - dig = {name="slimenodes_dug", gain=0.6, pitch=1.2}, - dug = {name="slimenodes_dug", gain=0.6}, - place = {name="slimenodes_place", gain=0.6}, - footstep = {name="slimenodes_step", gain=0.3}, + dig = { name = "slimenodes_dug", gain = 0.6, pitch = 1.2 }, + dug = { name = "slimenodes_dug", gain = 0.6 }, + place = { name = "slimenodes_place", gain = 0.6 }, + footstep = { name = "slimenodes_step", gain = 0.3 }, }, _mcl_blast_resistance = 0.6, _mcl_hardness = 0.6, @@ -55,7 +55,7 @@ minetest.register_craftitem("mcl_honey:honey_bottle", { _doc_items_longdesc = S("Honey Bottle is used to craft honey blocks and to restore hunger points."), _doc_items_usagehelp = S("Drinking will restore 6 hunger points. Can also be used to craft honey blocks."), inventory_image = "mcl_honey_honey_bottle.png", - groups = { craftitem = 1, food = 3, eatable = 6, can_eat_when_full=1 }, + groups = { craftitem = 1, food = 3, eatable = 6, can_eat_when_full = 1 }, on_place = minetest.item_eat(6, "mcl_potions:glass_bottle"), on_secondary_use = minetest.item_eat(6, "mcl_potions:glass_bottle"), _mcl_saturation = 1.2, @@ -65,21 +65,21 @@ minetest.register_craftitem("mcl_honey:honey_bottle", { minetest.register_node("mcl_honey:honey_block", { description = S("Honey Block"), _doc_items_longdesc = S("Honey Block. Used as a decoration and in redstone. Is sticky on some sides."), - tiles = {"mcl_honey_block_side.png"}, + tiles = { "mcl_honey_block_side.png" }, use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "blend" or true, groups = { handy = 1, deco_block = 1, fall_damage_add_percent = -80 }, sounds = { - dug = {name="slimenodes_dug", gain=0.6}, - place = {name="slimenodes_place", gain=0.6}, - footstep = {name="slimenodes_step", gain=0.3}, + dug = { name = "slimenodes_dug", gain = 0.6 }, + place = { name = "slimenodes_place", gain = 0.6 }, + footstep = { name = "slimenodes_step", gain = 0.3 }, }, paramtype = "light", drawtype = "nodebox", node_box = { type = "fixed", fixed = { - {-0.4, -0.4, -0.4, 0.4, 0.4, 0.4}, - {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + { -0.4, -0.4, -0.4, 0.4, 0.4, 0.4 }, + { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }, } }, selection_box = { @@ -107,7 +107,7 @@ minetest.register_node("mcl_honey:honey_block", { elseif name == "mesecons_pistons:piston_down_sticky_off" or name == "mesecons_pistons:piston_down_normal_off" then piston, piston_down = true, true end - if not( (piston_side and (n-1==neighbor_node.param2)) or (piston_up and (n==5)) or (piston_down and (n==6)) ) then + if not ((piston_side and (n - 1 == neighbor_node.param2)) or (piston_up and (n == 5)) or (piston_down and (n == 6))) then if piston and piston_pos then if piston_pos.x == neighbor_pos.x and piston_pos.y == neighbor_pos.y and piston_pos.z == neighbor_pos.z then -- Loopback to the same piston! Preventing unwanted behavior: From c4e4a8e4d2fe1f0860b7299634ec3f03f6fef93f Mon Sep 17 00:00:00 2001 From: Michieal Date: Sat, 4 Feb 2023 03:31:11 -0500 Subject: [PATCH 12/13] Move Waxing function to MCL_Honey. Remove commented code. --- mods/ITEMS/mcl_copper/functions.lua | 49 ----------------------------- mods/ITEMS/mcl_copper/nodes.lua | 16 ---------- mods/ITEMS/mcl_honey/init.lua | 26 +++++++++++++-- 3 files changed, 23 insertions(+), 68 deletions(-) diff --git a/mods/ITEMS/mcl_copper/functions.lua b/mods/ITEMS/mcl_copper/functions.lua index 2edb79b946..db756e4250 100644 --- a/mods/ITEMS/mcl_copper/functions.lua +++ b/mods/ITEMS/mcl_copper/functions.lua @@ -1,34 +1,5 @@ --local deepslate_mod = minetest.get_modpath("mcl_deepslate") ---[[ a basic on_place() -function mcl_copper.on_place (itemstack, placer, pointed_thing) - if pointed_thing.type ~= "node" then - return itemstack - end - local node = minetest.get_node(pointed_thing.under) - local pos = pointed_thing.under - local node_name = node.name - - if mcl_util.check_position_protection(pos, placer) then - return itemstack - end - - -- Use pointed node's on_rightclick function first, if present - local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) - if new_stack then - return new_stack - end - - local placed = ItemStack(itemstack:get_name()) - if not minetest.is_creative_enabled(placer:get_player_name()) then - itemstack:take_item() - end - minetest.item_place(placed, placer, pointed_thing, minetest.dir_to_facedir(vector.direction(pointed_thing.above, pointed_thing.under))) - - return itemstack -end ---]] - local function register_oxidation_abm(abm_name, node_name, oxidized_variant) minetest.register_abm({ label = abm_name, @@ -41,26 +12,6 @@ local function register_oxidation_abm(abm_name, node_name, oxidized_variant) }) end -function mcl_copper.waxing_copper_block(pos, node, player, itemstack) - -- prevent modification of protected nodes. - if mcl_util.check_position_protection(pos, player) then - return - end - - local def = minetest.registered_nodes[node.name] - - if def and def._mcl_copper_waxed_variant then - node.name = def._mcl_copper_waxed_variant - end - - minetest.set_node(pos, node) - awards.unlock(player:get_player_name(), "mcl:wax_on") - if not minetest.is_creative_enabled(player:get_player_name()) then - itemstack:take_item() - end - return itemstack -end - --[[ local stairs = { {"stair", "exposed", "_inner", "cut_inner"}, diff --git a/mods/ITEMS/mcl_copper/nodes.lua b/mods/ITEMS/mcl_copper/nodes.lua index 15a5a0fd7e..c8bb139cf7 100644 --- a/mods/ITEMS/mcl_copper/nodes.lua +++ b/mods/ITEMS/mcl_copper/nodes.lua @@ -35,7 +35,6 @@ minetest.register_node("mcl_copper:block", { _mcl_blast_resistance = 6, _mcl_hardness = 3, _mcl_copper_waxed_variant = "mcl_copper:waxed_block", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block", { @@ -48,7 +47,6 @@ minetest.register_node("mcl_copper:waxed_block", { _mcl_blast_resistance = 6, _mcl_hardness = 3, _mcl_stripped_variant = "mcl_copper:block", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_exposed", { @@ -62,7 +60,6 @@ minetest.register_node("mcl_copper:block_exposed", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed", _mcl_stripped_variant = "mcl_copper:block", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_exposed", { @@ -75,7 +72,6 @@ minetest.register_node("mcl_copper:waxed_block_exposed", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_weathered", { @@ -89,7 +85,6 @@ minetest.register_node("mcl_copper:block_weathered", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered", _mcl_stripped_variant = "mcl_copper:block_exposed", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_weathered", { @@ -102,7 +97,6 @@ minetest.register_node("mcl_copper:waxed_block_weathered", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_oxidized", { @@ -116,7 +110,6 @@ minetest.register_node("mcl_copper:block_oxidized", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized", _mcl_stripped_variant = "mcl_copper:block_weathered", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_oxidized", { @@ -129,7 +122,6 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_weathered", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_cut", { @@ -142,7 +134,6 @@ minetest.register_node("mcl_copper:block_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_cut", { @@ -155,7 +146,6 @@ minetest.register_node("mcl_copper:waxed_block_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_exposed_cut", { @@ -169,7 +159,6 @@ minetest.register_node("mcl_copper:block_exposed_cut", { _mcl_hardness = 5, _mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut", _mcl_stripped_variant = "mcl_copper:block_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_exposed_cut", { @@ -182,7 +171,6 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_weathered_cut", { @@ -196,7 +184,6 @@ minetest.register_node("mcl_copper:block_weathered_cut", { _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_weathered_cut", { @@ -209,7 +196,6 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_exposed_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:block_oxidized_cut", { @@ -223,7 +209,6 @@ minetest.register_node("mcl_copper:block_oxidized_cut", { _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_weathered_cut", _mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut", - --on_place = mcl_copper.on_place, }) minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { @@ -236,7 +221,6 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", { _mcl_blast_resistance = 6, _mcl_hardness = 5, _mcl_stripped_variant = "mcl_copper:block_weathered_cut", - --on_place = mcl_copper.on_place, }) mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut", diff --git a/mods/ITEMS/mcl_honey/init.lua b/mods/ITEMS/mcl_honey/init.lua index e7f0a5adf3..6edcb12877 100644 --- a/mods/ITEMS/mcl_honey/init.lua +++ b/mods/ITEMS/mcl_honey/init.lua @@ -1,11 +1,33 @@ --------------- ---- Honey ---- --------------- +mcl_honey = {} -- Variables local S = minetest.get_translator(minetest.get_current_modname()) local alldirs = { { x = 0, y = 0, z = 1 }, { x = 1, y = 0, z = 0 }, { x = 0, y = 0, z = -1 }, { x = -1, y = 0, z = 0 }, { x = 0, y = -1, z = 0 }, { x = 0, y = 1, z = 0 } } +-- Waxing Function +function mcl_honey.wax_block(pos, node, player, itemstack) + -- prevent modification of protected nodes. + if mcl_util.check_position_protection(pos, player) then + return + end + + local def = minetest.registered_nodes[node.name] + + if def and def._mcl_copper_waxed_variant then + node.name = def._mcl_copper_waxed_variant + end + + minetest.set_node(pos, node) + awards.unlock(player:get_player_name(), "mcl:wax_on") + if not minetest.is_creative_enabled(player:get_player_name()) then + itemstack:take_item() + end + return itemstack +end + -- Honeycomb minetest.register_craftitem("mcl_honey:honeycomb", { description = S("Honeycomb"), @@ -21,14 +43,12 @@ minetest.register_craftitem("mcl_honey:honeycomb", { local pos = pointed_thing.under local node_name = node.name - if minetest.get_modpath("mcl_copper") and mcl_copper then local def = minetest.registered_nodes[node_name] if def and def._mcl_copper_waxed_variant then -- wax the copper block. - return mcl_copper.waxing_copper_block(pos, node, placer, itemstack) + return mcl_honey.wax_block(pos, node, placer, itemstack) end - end end, }) From 46ca650ea4dce5ce432923fde7c46b65e34e9d81 Mon Sep 17 00:00:00 2001 From: Michieal Date: Sat, 4 Feb 2023 16:31:18 -0500 Subject: [PATCH 13/13] further optimize and reformat mcl_honey's init.lua --- mods/ITEMS/mcl_honey/init.lua | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_honey/init.lua b/mods/ITEMS/mcl_honey/init.lua index 6edcb12877..e4b403875e 100644 --- a/mods/ITEMS/mcl_honey/init.lua +++ b/mods/ITEMS/mcl_honey/init.lua @@ -41,14 +41,9 @@ minetest.register_craftitem("mcl_honey:honeycomb", { end local node = minetest.get_node(pointed_thing.under) local pos = pointed_thing.under - local node_name = node.name - local def = minetest.registered_nodes[node_name] - - if def and def._mcl_copper_waxed_variant then - -- wax the copper block. - return mcl_honey.wax_block(pos, node, placer, itemstack) - end + -- wax the block. This is the only viable usage of honeycomb's on_place. If it "fails" to wax, then nothing is changed. + return mcl_honey.wax_block(pos, node, placer, itemstack) end, })