2022-05-04 11:07:04 +02:00
--local deepslate_mod = minetest.get_modpath("mcl_deepslate")
2023-02-03 20:09:16 +01:00
--[[ a basic on_place()
2023-01-31 00:27:53 +01:00
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
2023-02-03 20:09:16 +01:00
--]]
2023-01-31 00:27:53 +01:00
2022-05-01 03:11:51 +02:00
local function register_oxidation_abm ( abm_name , node_name , oxidized_variant )
minetest.register_abm ( {
label = abm_name ,
2023-01-31 00:27:53 +01:00
nodenames = { node_name } ,
2022-05-01 03:11:51 +02:00
interval = 500 ,
chance = 3 ,
action = function ( pos , node )
2023-01-31 00:27:53 +01:00
minetest.swap_node ( pos , { name = oxidized_variant , param2 = node.param2 } )
2022-05-04 11:07:04 +02:00
end ,
2022-05-01 03:11:51 +02:00
} )
end
2023-02-02 00:39:13 +01:00
function mcl_copper . waxing_copper_block ( pos , node , player , itemstack )
2023-02-03 20:09:16 +01:00
-- prevent modification of protected nodes.
if mcl_util.check_position_protection ( pos , player ) then
return
end
2023-01-31 00:27:53 +01:00
2023-02-03 20:09:16 +01:00
local def = minetest.registered_nodes [ node.name ]
2023-01-31 00:27:53 +01:00
2023-02-03 20:09:16 +01:00
if def and def._mcl_copper_waxed_variant then
node.name = def._mcl_copper_waxed_variant
end
2023-01-31 00:27:53 +01:00
2023-02-03 20:09:16 +01:00
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 ( )
2022-11-15 22:02:05 +01:00
end
2023-02-03 20:09:16 +01:00
return itemstack
2022-11-15 22:02:05 +01:00
end
2022-05-04 11:07:04 +02:00
--[[
2022-05-01 03:11:51 +02:00
local stairs = {
{ " stair " , " exposed " , " _inner " , " cut_inner " } ,
{ " stair " , " weathered " , " _inner " , " exposed_cut_inner " } ,
{ " stair " , " exposed " , " _outer " , " cut_outer " } ,
{ " stair " , " weathered " , " _outer " , " exposed_cut_outer " } ,
{ " stair " , " oxidized " , " _outer " , " weathered_cut_outer " } ,
{ " stair " , " oxidized " , " _inner " , " weathered_cut_inner " } ,
{ " slab " , " exposed " , " " , " cut " } ,
{ " slab " , " oxidized " , " " , " weathered_cut " } ,
{ " slab " , " weathered " , " " , " exposed_cut " } ,
{ " slab " , " exposed " , " _top " , " cut_top " } ,
{ " slab " , " oxidized " , " _top " , " weathered_cut_top " } ,
{ " slab " , " weathered " , " _top " , " exposed_cut_top " } ,
{ " slab " , " exposed " , " _double " , " cut_double " } ,
{ " slab " , " oxidized " , " _double " , " weathered_cut_double " } ,
{ " slab " , " weathered " , " _double " , " exposed_cut_double " } ,
{ " stair " , " exposed " , " " , " cut " } ,
{ " stair " , " oxidized " , " " , " weathered_cut " } ,
2022-05-04 11:07:04 +02:00
{ " stair " , " weathered " , " " , " exposed_cut " } ,
} ] ]
2022-05-01 03:11:51 +02:00
local block_oxidation = {
2023-01-31 00:27:53 +01:00
{ " " , " _exposed " } ,
{ " _cut " , " _exposed_cut " } ,
{ " _exposed " , " _weathered " } ,
{ " _exposed_cut " , " _weathered_cut " } ,
{ " _weathered " , " _oxidized " } ,
{ " _weathered_cut " , " _oxidized_cut " }
2022-05-01 03:11:51 +02:00
}
local stair_oxidation = {
2023-01-31 00:27:53 +01:00
{ " 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 " }
2022-05-01 03:11:51 +02:00
}
for _ , b in pairs ( block_oxidation ) do
2023-01-31 00:27:53 +01:00
register_oxidation_abm ( " Copper oxidation " , " mcl_copper:block " .. b [ 1 ] , " mcl_copper:block " .. b [ 2 ] )
2022-05-01 03:11:51 +02:00
end
for _ , s in pairs ( stair_oxidation ) do
2023-01-31 00:27:53 +01:00
register_oxidation_abm ( " Copper oxidation " , " mcl_stairs: " .. s [ 1 ] .. " _copper_ " .. s [ 2 ] , " mcl_stairs: " .. s [ 1 ] .. " _copper_ " .. s [ 3 ] )
2023-02-02 05:49:04 +01:00
-- 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.
2022-05-01 03:11:51 +02:00
end
2022-05-04 11:07:04 +02:00