2023-11-19 01:48:35 +01:00
|
|
|
local S = minetest.get_translator()
|
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
local function create_soil(itemstack, player, pointed_thing)
|
|
|
|
local pos = pointed_thing.under
|
|
|
|
local name = minetest.get_node(pos).name
|
2024-01-26 17:52:38 +01:00
|
|
|
local above_name = minetest.get_node(vector.offset(pos,0,1,0)).name
|
2023-06-21 23:45:22 +02:00
|
|
|
|
|
|
|
if minetest.is_protected(pointed_thing.under, player:get_player_name()) then
|
|
|
|
minetest.record_protection_violation(pointed_thing.under, player:get_player_name())
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
if minetest.get_item_group(name, "cultivatable") == 2 then
|
|
|
|
if above_name == "air" then
|
2024-02-23 19:53:21 +01:00
|
|
|
minetest.set_node(pos, {name="mcl_farming:soil"})
|
2023-06-21 23:45:22 +02:00
|
|
|
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.5 }, true)
|
|
|
|
end
|
|
|
|
elseif minetest.get_item_group(name, "cultivatable") == 1 then
|
|
|
|
if above_name == "air" then
|
2024-02-23 19:53:21 +01:00
|
|
|
minetest.set_node(pos, {name="mcl_core:dirt"})
|
2023-06-21 23:45:22 +02:00
|
|
|
minetest.sound_play("default_dig_crumbly", { pos = pos, gain = 0.6 }, true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end
|
|
|
|
|
|
|
|
local hoe_function
|
|
|
|
|
2023-09-29 01:23:49 +02:00
|
|
|
if exchangeclone.mcl then
|
2023-06-21 23:45:22 +02:00
|
|
|
hoe_function = create_soil
|
|
|
|
else
|
2023-11-19 01:48:35 +01:00
|
|
|
if farming then
|
|
|
|
hoe_function = farming.hoe_on_use
|
|
|
|
else
|
|
|
|
hoe_function = function(...) end
|
|
|
|
end
|
2023-06-21 23:45:22 +02:00
|
|
|
end
|
|
|
|
|
2024-01-26 17:52:38 +01:00
|
|
|
function exchangeclone.hoe_action(itemstack, player, center)
|
|
|
|
if not (itemstack and player and center) then return end
|
|
|
|
if exchangeclone.check_cooldown(player, "hoe") then return end
|
|
|
|
local charge = math.max(itemstack:get_meta():get_int("exchangeclone_tool_charge"), 1)
|
|
|
|
local nodes
|
|
|
|
if charge > 1 then
|
|
|
|
local vector1, vector2 = exchangeclone.process_range(player, "flat", charge)
|
|
|
|
if not (vector1 and vector2) then return end
|
|
|
|
local pos1, pos2 = vector.add(center, vector1), vector.add(center, vector2)
|
2024-02-23 19:53:21 +01:00
|
|
|
nodes = minetest.find_nodes_in_area(pos1, pos2, {"group:exchangeclone_dirt"})
|
2024-02-13 01:25:25 +01:00
|
|
|
exchangeclone.play_sound(player, "exchangeclone_charge_up")
|
2024-01-26 17:52:38 +01:00
|
|
|
else
|
|
|
|
nodes = {center}
|
|
|
|
end
|
2024-02-23 19:53:21 +01:00
|
|
|
|
2024-01-26 17:52:38 +01:00
|
|
|
for _, pos in pairs(nodes) do
|
|
|
|
if minetest.is_protected(pos, player:get_player_name()) then
|
|
|
|
minetest.record_protection_violation(pos, player:get_player_name())
|
|
|
|
else
|
|
|
|
local new_pointed_thing = {type = "node", under = pos, above = vector.offset(pos,0,1,0)}
|
2024-02-23 19:53:21 +01:00
|
|
|
hoe_function(itemstack, player, new_pointed_thing, 0)
|
2023-08-07 22:56:29 +02:00
|
|
|
end
|
|
|
|
end
|
2024-01-26 17:52:38 +01:00
|
|
|
|
2024-02-23 19:53:21 +01:00
|
|
|
if charge > 1 then
|
2024-01-26 17:52:38 +01:00
|
|
|
exchangeclone.start_cooldown(player, "hoe", charge/4)
|
|
|
|
end
|
|
|
|
end
|
2023-08-07 22:56:29 +02:00
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
local hoe_on_place = function(itemstack, player, pointed_thing)
|
|
|
|
local click_test = exchangeclone.check_on_rightclick(itemstack, player, pointed_thing)
|
|
|
|
if click_test ~= false then
|
|
|
|
return click_test
|
|
|
|
end
|
|
|
|
|
|
|
|
if player:get_player_control().aux1 then
|
2024-01-26 17:52:38 +01:00
|
|
|
return exchangeclone.charge_update(itemstack, player)
|
2023-06-21 23:45:22 +02:00
|
|
|
end
|
2023-08-07 22:56:29 +02:00
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
if player:get_player_control().sneak then
|
2024-01-26 17:52:38 +01:00
|
|
|
local meta = itemstack:get_meta()
|
|
|
|
local current_mode = meta:get_string("exchangeclone_multidig_mode")
|
|
|
|
if current_mode == "3x3" then
|
|
|
|
meta:set_string("exchangeclone_multidig_mode", "1x1")
|
2023-11-19 01:48:35 +01:00
|
|
|
minetest.chat_send_player(player:get_player_name(), S("Single node mode"))
|
2023-06-21 23:45:22 +02:00
|
|
|
else
|
2024-01-26 17:52:38 +01:00
|
|
|
meta:set_string("exchangeclone_multidig_mode", "3x3")
|
2023-11-19 01:48:35 +01:00
|
|
|
minetest.chat_send_player(player:get_player_name(), S("3x3 mode"))
|
2023-06-21 23:45:22 +02:00
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end
|
2023-08-07 22:56:29 +02:00
|
|
|
if pointed_thing.type == "node" then
|
2024-01-26 17:52:38 +01:00
|
|
|
local node_name = minetest.get_node(pointed_thing.under).name
|
|
|
|
local def = minetest.registered_nodes[node_name]
|
|
|
|
if minetest.get_item_group(node_name, "cultivatable") > 0
|
|
|
|
or (minetest.get_item_group(node_name, "soil") > 0 and
|
|
|
|
(def.soil and def.soil.wet and def.soil.dry)) then
|
|
|
|
exchangeclone.hoe_action(itemstack, player, pointed_thing.under)
|
|
|
|
end
|
2023-06-21 23:45:22 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-09-29 01:23:49 +02:00
|
|
|
if exchangeclone.mcl then
|
2023-06-21 23:45:22 +02:00
|
|
|
mcl_autogroup.register_diggroup("exchangeclone_dirt")
|
|
|
|
end
|
|
|
|
for name, def in pairs(minetest.registered_nodes) do
|
|
|
|
local is_dirt = minetest.get_item_group(name, "cultivatable") + minetest.get_item_group(name, "soil")
|
|
|
|
if is_dirt > 0 then
|
|
|
|
if not name:find("sand") then
|
|
|
|
local item_groups = table.copy(def.groups)
|
|
|
|
item_groups.exchangeclone_dirt = 1
|
|
|
|
minetest.override_item(name, {groups = item_groups})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-01-26 17:52:38 +01:00
|
|
|
minetest.register_tool("exchangeclone:dark_matter_hoe", {
|
2023-11-19 01:48:35 +01:00
|
|
|
description = S("Dark Matter Hammer").."\n"..S("Single node mode"),
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_image = "exchangeclone_dark_matter_hoe.png",
|
|
|
|
inventory_image = "exchangeclone_dark_matter_hoe.png",
|
|
|
|
wield_scale = exchangeclone.wield_scale,
|
|
|
|
on_place = hoe_on_place,
|
|
|
|
on_secondary_use = hoe_on_place,
|
2023-10-07 17:26:21 +02:00
|
|
|
groups = { tool=1, hoe=1, enchantability=0, dark_matter_hoe = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-06-21 23:45:22 +02:00
|
|
|
tool_capabilities = {
|
|
|
|
full_punch_interval = 0.25,
|
2024-01-26 17:52:38 +01:00
|
|
|
damage_groups = { fleshy = 1, },
|
2023-06-21 23:45:22 +02:00
|
|
|
groupcaps={
|
2024-02-15 22:00:26 +01:00
|
|
|
exchangeclone_dirt = {times=exchangeclone.get_mtg_times(14, nil, "crumbly"), uses=0, maxlevel=4},
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
_mcl_toollike_wield = true,
|
|
|
|
_mcl_diggroups = {
|
2024-02-04 22:29:48 +01:00
|
|
|
exchangeclone_dirt = { speed = 14, level = 5, uses = 0 },
|
|
|
|
hoey = { speed = 14, level = 5, uses = 0 }
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
2024-02-16 22:44:08 +01:00
|
|
|
wear_represents = "exchangeclone_charge_level"
|
2024-01-26 17:52:38 +01:00
|
|
|
})
|
2023-08-07 22:56:29 +02:00
|
|
|
|
2024-01-26 17:52:38 +01:00
|
|
|
exchangeclone.register_multidig_tool("exchangeclone:dark_matter_hoe", {"group:exchangeclone_dirt"})
|
|
|
|
minetest.register_alias("exchangeclone:dark_matter_hoe_3x3", "exchangeclone:dark_matter_hoe")
|
|
|
|
exchangeclone.set_charge_type("exchangeclone:dark_matter_hoe", "dark_matter")
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2024-01-26 17:52:38 +01:00
|
|
|
minetest.register_tool("exchangeclone:red_matter_hoe", {
|
|
|
|
description = S("Red Matter Hammer").."\n"..S("Single node mode"),
|
|
|
|
wield_image = "exchangeclone_red_matter_hoe.png",
|
|
|
|
inventory_image = "exchangeclone_red_matter_hoe.png",
|
|
|
|
wield_scale = exchangeclone.wield_scale,
|
|
|
|
on_place = hoe_on_place,
|
|
|
|
on_secondary_use = hoe_on_place,
|
|
|
|
groups = { tool=1, hoe=1, enchantability=0, red_matter_hoe = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
|
|
|
tool_capabilities = {
|
|
|
|
full_punch_interval = 0.25,
|
|
|
|
damage_groups = { fleshy = 1, },
|
|
|
|
groupcaps={
|
2024-02-15 22:00:26 +01:00
|
|
|
exchangeclone_dirt = {times=exchangeclone.get_mtg_times(16, nil, "crumbly"), uses=0, maxlevel=4},
|
2024-01-26 17:52:38 +01:00
|
|
|
},
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
2024-01-26 17:52:38 +01:00
|
|
|
_mcl_toollike_wield = true,
|
|
|
|
_mcl_diggroups = {
|
2024-02-04 22:29:48 +01:00
|
|
|
exchangeclone_dirt = { speed = 16, level = 6, uses = 0 },
|
|
|
|
hoey = { speed = 16, level = 6, uses = 0 }
|
2024-01-26 17:52:38 +01:00
|
|
|
},
|
2024-02-16 22:44:08 +01:00
|
|
|
wear_represents = "exchangeclone_charge_level"
|
2024-01-26 17:52:38 +01:00
|
|
|
})
|
2023-06-21 23:45:22 +02:00
|
|
|
|
2024-01-26 17:52:38 +01:00
|
|
|
exchangeclone.register_multidig_tool("exchangeclone:red_matter_hoe", {"group:exchangeclone_dirt"})
|
|
|
|
minetest.register_alias("exchangeclone:red_matter_hoe_3x3", "exchangeclone:red_matter_hoe")
|
|
|
|
exchangeclone.set_charge_type("exchangeclone:red_matter_hoe", "red_matter")
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:dark_matter_hoe",
|
|
|
|
recipe = {
|
2023-06-23 23:02:22 +02:00
|
|
|
{"exchangeclone:dark_matter", "exchangeclone:dark_matter"},
|
2023-11-10 03:35:23 +01:00
|
|
|
{"", exchangeclone.itemstrings.diamond},
|
|
|
|
{"", exchangeclone.itemstrings.diamond}
|
2023-06-21 23:45:22 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:red_matter_hoe",
|
|
|
|
recipe = {
|
2023-06-23 23:02:22 +02:00
|
|
|
{"exchangeclone:red_matter", "exchangeclone:red_matter"},
|
|
|
|
{"", "group:dark_matter_hoe"},
|
|
|
|
{"", "exchangeclone:dark_matter"}
|
2023-06-21 23:45:22 +02:00
|
|
|
}
|
|
|
|
})
|