1
0
Fork 0

Everything *BUT* scraping works properly.

This commit is contained in:
Michieal 2023-02-01 18:39:13 -05:00
parent 03379ba0d7
commit bceacd59b1
4 changed files with 35 additions and 22 deletions

View File

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

View File

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

View File

@ -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", {

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