1
0
Fork 0

Oxidation, scrapping and waxing for copper doors

copper-adaptation-refs-recovery
JoseDouglas26 2024-02-16 12:35:43 -03:00
parent 802137f355
commit f83d1b18cd
4 changed files with 64 additions and 16 deletions

View File

@ -6,6 +6,15 @@ minetest.register_abm({
action = function(pos, node)
local def = minetest.registered_nodes[node.name]
if def and def._mcl_oxidized_variant then
if def.groups.door == 1 then
if node.name:find("_b_") then
local top_pos = { x = pos.x, y = pos.y + 1, z = pos.z }
minetest.set_node(top_pos, { name = def._mcl_oxidized_variant:gsub("_b_", "_t_"), param2 = node.param2 })
elseif node.name:find("_t_") then
local bot_pos = { x = pos.x, y = pos.y - 1, z = pos.z }
minetest.set_node(bot_pos, { name = def._mcl_oxidized_variant:gsub("_t_", "_b_"), param2 = node.param2 })
end
end
minetest.set_node(pos, { name = def._mcl_oxidized_variant, param2 = node.param2 })
end
end,

View File

@ -21,6 +21,16 @@ function mcl_copper.register_oxidation_and_scraping(mod_name, subname, decay_cha
elseif subname:find("trapdoor") then
minetest.override_item(item.."_open", {_mcl_oxidized_variant = oxidized_item.."_open"})
minetest.override_item(oxidized_item.."_open", {_mcl_stripped_variant = item.."_open"})
elseif subname == "door" then
minetest.override_item(item.."_b_1", {_mcl_oxidized_variant = oxidized_item.."_b_1"})
minetest.override_item(oxidized_item.."_b_1", {_mcl_stripped_variant = item.."_b_1"})
minetest.override_item(item.."_t_1", {_mcl_oxidized_variant = oxidized_item.."_t_1"})
minetest.override_item(oxidized_item.."_t_1", {_mcl_stripped_variant = item.."_t_1"})
minetest.override_item(item.."_b_2", {_mcl_oxidized_variant = oxidized_item.."_b_2"})
minetest.override_item(oxidized_item.."_b_2", {_mcl_stripped_variant = item.."_b_2"})
minetest.override_item(item.."_t_2", {_mcl_oxidized_variant = oxidized_item.."_t_2"})
minetest.override_item(oxidized_item.."_t_2", {_mcl_stripped_variant = item.."_t_2"})
end
end
end
@ -48,6 +58,16 @@ function mcl_copper.register_waxing_and_scraping(mod_name, subname, decay_chain)
elseif subname:find("trapdoor") then
minetest.override_item(waxed_item.."_open", {_mcl_stripped_variant = unwaxed_item.."_open"})
minetest.override_item(unwaxed_item.."_open", {_mcl_waxed_variant = waxed_item.."_open"})
elseif subname == "waxed_door" then
minetest.override_item(waxed_item.."_b_1", {_mcl_stripped_variant = unwaxed_item.."_b_1"})
minetest.override_item(unwaxed_item.."_b_1", {_mcl_waxed_variant = waxed_item.."_b_1"})
minetest.override_item(waxed_item.."_t_1", {_mcl_stripped_variant = unwaxed_item.."_t_1"})
minetest.override_item(unwaxed_item.."_t_1", {_mcl_waxed_variant = waxed_item.."_t_1"})
minetest.override_item(waxed_item.."_b_2", {_mcl_stripped_variant = unwaxed_item.."_b_2"})
minetest.override_item(unwaxed_item.."_b_2", {_mcl_waxed_variant = waxed_item.."_b_2"})
minetest.override_item(waxed_item.."_t_2", {_mcl_stripped_variant = unwaxed_item.."_t_2"})
minetest.override_item(unwaxed_item.."_t_2", {_mcl_waxed_variant = waxed_item.."_t_2"})
end
end
end
@ -58,13 +78,7 @@ local cut_decay_chain = {
"_weathered_cut",
"_oxidized_cut"
}
local trapdoor_decay_chain = {
"",
"_exposed",
"_weathered",
"_oxidized"
}
local waxed_trapdoor_decay_chain = {
local doors_decay_chain = {
"",
"_exposed",
"_weathered",
@ -73,7 +87,9 @@ local waxed_trapdoor_decay_chain = {
mcl_copper.register_oxidation_and_scraping("mcl_stairs", "stair_copper", cut_decay_chain)
mcl_copper.register_oxidation_and_scraping("mcl_stairs", "slab_copper", cut_decay_chain)
mcl_copper.register_oxidation_and_scraping("mcl_copper", "trapdoor", trapdoor_decay_chain)
mcl_copper.register_oxidation_and_scraping("mcl_copper", "trapdoor", doors_decay_chain)
mcl_copper.register_oxidation_and_scraping("mcl_copper", "door", doors_decay_chain)
mcl_copper.register_waxing_and_scraping("mcl_stairs", "stair_waxed_copper", cut_decay_chain)
mcl_copper.register_waxing_and_scraping("mcl_stairs", "slab_waxed_copper", cut_decay_chain)
mcl_copper.register_waxing_and_scraping("mcl_copper", "waxed_trapdoor", waxed_trapdoor_decay_chain)
mcl_copper.register_waxing_and_scraping("mcl_copper", "waxed_trapdoor", doors_decay_chain)
mcl_copper.register_waxing_and_scraping("mcl_copper", "waxed_door", doors_decay_chain)

View File

@ -8,22 +8,35 @@ 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)
function mcl_honey.wax_block(pos, node, player, itemstack, pointed_thing)
-- 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_waxed_variant then
node.name = def._mcl_waxed_variant
if player:get_player_control().sneak then
if def and def._mcl_waxed_variant then
if def.groups.door == 1 then
if node.name:find("_b_") then
local top_pos = { x = pos.x, y = pos.y + 1, z = pos.z }
minetest.swap_node(top_pos, { name = def._mcl_waxed_variant:gsub("_b_", "_t_") })
elseif node.name:find("_t_") then
local bot_pos = { x = pos.x, y = pos.y - 1, z = pos.z }
minetest.swap_node(bot_pos, { name = def._mcl_waxed_variant:gsub("_t_", "_b_") })
end
end
else
return
end
else
return
if def and def.on_rightclick then
return def.on_rightclick(pos, node, player, itemstack, pointed_thing)
end
end
node.name = def._mcl_waxed_variant
minetest.set_node(pos, node)
minetest.swap_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()
@ -46,7 +59,7 @@ minetest.register_craftitem("mcl_honey:honeycomb", {
local pos = pointed_thing.under
-- 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)
return mcl_honey.wax_block(pos, node, placer, itemstack, pointed_thing)
end,
})

View File

@ -410,6 +410,16 @@ local function make_stripped_trunk(itemstack, placer, pointed_thing)
if noddef._mcl_stripped_variant == nil then
return itemstack
else
if noddef.groups.door == 1 then
local pt_under = pointed_thing.under
if node_name:find("_b_") then
local top_pos = {x = pt_under.x, y = pt_under.y + 1, z = pt_under.z}
minetest.swap_node(top_pos, {name=noddef._mcl_stripped_variant:gsub("_b_", "_t_")})
elseif node_name:find("_t_") then
local bot_pos = {x = pt_under.x, y = pt_under.y - 1, z = pt_under.z}
minetest.swap_node(bot_pos, {name=noddef._mcl_stripped_variant:gsub("_t_", "_b_")})
end
end
minetest.swap_node(pointed_thing.under, {name=noddef._mcl_stripped_variant, param2=node.param2})
if minetest.get_item_group(node_name, "waxed") ~= 0 then
awards.unlock(placer:get_player_name(), "mcl:wax_off")