1
0
Fork 0

Merge pull request 'fix_copper_blocks' (#3390) from fix_copper_blocks into master

Reviewed-on: MineClone2/MineClone2#3390
Reviewed-by: 𝕵𝖔𝖍𝖆𝖓𝖓𝖊𝖘 𝕱𝖗𝖎𝖙𝖟 <mrrar@noreply.git.minetest.land>
Reviewed-by: ancientmarinerdev <ancientmariner_dev@proton.me>
This commit is contained in:
ancientmarinerdev 2023-02-06 23:16:11 +00:00
commit d72a674097
6 changed files with 100 additions and 200 deletions

View File

@ -12,34 +12,6 @@ local function register_oxidation_abm(abm_name, node_name, oxidized_variant)
})
end
function waxing_copper_block(pos, node, player, itemstack, convert_to)
if itemstack:get_name() == "mcl_honey:honeycomb" then
node.name = convert_to
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
else
return true
end
end
function scraping_copper_block(pos, node, player, itemstack, convert_to)
if itemstack:get_name():find("axe") then
node.name = convert_to
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)
end
else
return true
end
end
--[[
local stairs = {
{"stair", "exposed", "_inner", "cut_inner"},
@ -62,107 +34,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" },
@ -199,11 +70,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
]]

View File

@ -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")

View File

@ -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.

View File

@ -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,7 +34,7 @@ minetest.register_node("mcl_copper:block", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 3,
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block") end,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block",
})
minetest.register_node("mcl_copper:waxed_block", {
@ -47,7 +46,7 @@ minetest.register_node("mcl_copper:waxed_block", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 3,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end,
_mcl_stripped_variant = "mcl_copper:block",
})
minetest.register_node("mcl_copper:block_exposed", {
@ -59,8 +58,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",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed") end,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed",
_mcl_stripped_variant = "mcl_copper:block",
})
minetest.register_node("mcl_copper:waxed_block_exposed", {
@ -72,7 +71,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block") end,
_mcl_stripped_variant = "mcl_copper:block",
})
minetest.register_node("mcl_copper:block_weathered", {
@ -84,8 +83,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",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered") end,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered",
_mcl_stripped_variant = "mcl_copper:block_exposed",
})
minetest.register_node("mcl_copper:waxed_block_weathered", {
@ -97,7 +96,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed") end,
_mcl_stripped_variant = "mcl_copper:block_exposed",
})
minetest.register_node("mcl_copper:block_oxidized", {
@ -109,8 +108,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",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized") end,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized",
_mcl_stripped_variant = "mcl_copper:block_weathered",
})
minetest.register_node("mcl_copper:waxed_block_oxidized", {
@ -122,7 +121,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered") end,
_mcl_stripped_variant = "mcl_copper:block_weathered",
})
minetest.register_node("mcl_copper:block_cut", {
@ -134,7 +133,7 @@ minetest.register_node("mcl_copper:block_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_cut") end,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_cut",
})
minetest.register_node("mcl_copper:waxed_block_cut", {
@ -146,7 +145,7 @@ minetest.register_node("mcl_copper:waxed_block_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end,
_mcl_stripped_variant = "mcl_copper:block_cut",
})
minetest.register_node("mcl_copper:block_exposed_cut", {
@ -158,8 +157,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",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_exposed_cut") end,
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_exposed_cut",
_mcl_stripped_variant = "mcl_copper:block_cut",
})
minetest.register_node("mcl_copper:waxed_block_exposed_cut", {
@ -171,7 +170,7 @@ minetest.register_node("mcl_copper:waxed_block_exposed_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_cut") end,
_mcl_stripped_variant = "mcl_copper:block_cut",
})
minetest.register_node("mcl_copper:block_weathered_cut", {
@ -183,8 +182,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",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_weathered_cut") end,
_mcl_stripped_variant = "mcl_copper:block_exposed_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_weathered_cut",
})
minetest.register_node("mcl_copper:waxed_block_weathered_cut", {
@ -196,7 +195,7 @@ minetest.register_node("mcl_copper:waxed_block_weathered_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_exposed_cut") end,
_mcl_stripped_variant = "mcl_copper:block_exposed_cut",
})
minetest.register_node("mcl_copper:block_oxidized_cut", {
@ -208,8 +207,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",
on_rightclick = function(pos, node, player, itemstack) waxing_copper_block(pos, node, player, itemstack, "mcl_copper:waxed_block_oxidized_cut") end,
_mcl_stripped_variant = "mcl_copper:block_weathered_cut",
_mcl_copper_waxed_variant = "mcl_copper:waxed_block_oxidized_cut",
})
minetest.register_node("mcl_copper:waxed_block_oxidized_cut", {
@ -221,7 +220,7 @@ minetest.register_node("mcl_copper:waxed_block_oxidized_cut", {
sounds = mcl_sounds.node_sound_metal_defaults(),
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
on_rightclick = function(pos, node, player, itemstack) scraping_copper_block(pos, node, player, itemstack, "mcl_copper:block_weathered_cut") end,
_mcl_stripped_variant = "mcl_copper:block_weathered_cut",
})
mcl_stairs.register_slab("copper_cut", "mcl_copper:block_cut",

View File

@ -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"),
@ -13,6 +35,16 @@ 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
-- 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,
})
minetest.register_node("mcl_honey:honeycomb_block", {

View File

@ -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