2023-11-19 01:48:35 +01:00
|
|
|
local S = minetest.get_translator()
|
|
|
|
|
2023-08-07 22:56:29 +02:00
|
|
|
exchangeclone.hammer_action = {
|
2023-11-19 01:48:35 +01:00
|
|
|
start_action = function(player, center, range, itemstack)
|
2023-08-07 22:56:29 +02:00
|
|
|
if exchangeclone.check_cooldown(player, "hammer") then return end
|
|
|
|
local data = {}
|
|
|
|
exchangeclone.play_ability_sound(player)
|
2023-11-19 01:48:35 +01:00
|
|
|
data.itemstack = itemstack
|
2023-12-15 00:09:59 +01:00
|
|
|
data.remove_positions = {}
|
2023-08-07 22:56:29 +02:00
|
|
|
return data
|
|
|
|
end,
|
|
|
|
action = function(player, pos, node, data)
|
2024-01-22 16:18:52 +01:00
|
|
|
if minetest.get_item_group(node.name, exchangeclone.stone_group) ~= 0 then
|
2023-08-07 22:56:29 +02:00
|
|
|
if minetest.is_protected(pos, player:get_player_name()) then
|
|
|
|
minetest.record_protection_violation(pos, player:get_player_name())
|
|
|
|
else
|
2023-11-19 01:48:35 +01:00
|
|
|
local drops = minetest.get_node_drops(node.name, data.itemstack)
|
2023-08-07 22:56:29 +02:00
|
|
|
exchangeclone.drop_items_on_player(pos, drops, player)
|
2023-12-15 00:09:59 +01:00
|
|
|
table.insert(data.remove_positions, pos)
|
2023-08-07 22:56:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return data
|
|
|
|
end,
|
|
|
|
end_action = function(player, center, range, data)
|
2023-12-15 00:09:59 +01:00
|
|
|
exchangeclone.remove_nodes(data.remove_positions)
|
2024-01-22 16:18:52 +01:00
|
|
|
exchangeclone.start_cooldown(player, "hammer", range/2) -- The hammer has by far the most lag potential and therefore a longer cooldown.
|
2023-08-07 22:56:29 +02:00
|
|
|
end
|
|
|
|
}
|
2023-06-21 23:45:22 +02:00
|
|
|
|
|
|
|
local function hammer_on_place(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
|
|
|
|
if itemstack:get_name():find("dark") then
|
|
|
|
return exchangeclone.range_update(itemstack, player, 3)
|
|
|
|
else
|
|
|
|
return exchangeclone.range_update(itemstack, player, 4)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if player:get_player_control().sneak then
|
2024-01-22 16:18:52 +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")
|
|
|
|
exchangeclone.update_tool_capabilities(itemstack)
|
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-22 16:18:52 +01:00
|
|
|
meta:set_string("exchangeclone_multidig_mode", "3x3")
|
|
|
|
exchangeclone.update_tool_capabilities(itemstack)
|
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
|
|
|
|
|
|
|
|
local range = itemstack:get_meta():get_int("exchangeclone_item_range")
|
|
|
|
local center = player:get_pos()
|
|
|
|
if pointed_thing.type == "node" then
|
|
|
|
center = pointed_thing.under
|
|
|
|
end
|
2023-11-19 01:48:35 +01:00
|
|
|
exchangeclone.node_radius_action(player, center, range, exchangeclone.hammer_action, itemstack)
|
2023-06-21 23:45:22 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_tool("exchangeclone:dark_matter_hammer", {
|
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_hammer.png",
|
|
|
|
inventory_image = "exchangeclone_dark_matter_hammer.png",
|
2023-12-25 18:56:50 +01:00
|
|
|
groups = { tool=1, hammer=1, dig_speed_class=5, enchantability=0, dark_matter_hammer = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_scale = exchangeclone.wield_scale,
|
|
|
|
tool_capabilities = {
|
|
|
|
-- 1/1.2
|
|
|
|
full_punch_interval = 0.5,
|
2023-10-30 23:42:11 +01:00
|
|
|
max_drop_level=6,
|
2023-06-21 23:45:22 +02:00
|
|
|
damage_groups = {fleshy=7},
|
|
|
|
punch_attack_uses = 0,
|
|
|
|
groupcaps={
|
|
|
|
cracky = {times={[1]=1.5, [2]=0.75, [3]=0.325}, uses=0, maxlevel=4},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_mcl_toollike_wield = true,
|
|
|
|
_mcl_diggroups = {
|
2023-12-25 18:56:50 +01:00
|
|
|
pickaxey = { speed = 16, level = 5, uses = 0 }
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
|
|
|
on_place = hammer_on_place,
|
|
|
|
on_secondary_use = hammer_on_place,
|
2024-01-22 16:18:52 +01:00
|
|
|
exchangeclone_multidig_mode = "1x1",
|
|
|
|
on_dig = exchangeclone.multi_on_dig(exchangeclone.stone_group)
|
2023-06-21 23:45:22 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_tool("exchangeclone:dark_matter_hammer_3x3", {
|
2023-11-19 01:48:35 +01:00
|
|
|
description = S("Dark Matter Hammer").."\n"..S("3x3 mode"),
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_image = "exchangeclone_dark_matter_hammer.png",
|
|
|
|
inventory_image = "exchangeclone_dark_matter_hammer.png",
|
2023-12-25 18:56:50 +01:00
|
|
|
groups = { tool=1, hammer=1, dig_speed_class=5, enchantability=0, dark_matter_hammer = 1, not_in_creative_inventory = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_scale = exchangeclone.wield_scale,
|
|
|
|
tool_capabilities = {
|
|
|
|
-- 1/1.2
|
|
|
|
full_punch_interval = 0.5,
|
2023-10-30 23:42:11 +01:00
|
|
|
max_drop_level=6,
|
2023-06-21 23:45:22 +02:00
|
|
|
damage_groups = {fleshy=7},
|
|
|
|
punch_attack_uses = 0,
|
|
|
|
groupcaps={
|
|
|
|
cracky = {times={[1]=1.8, [2]=0.9, [3]=0.5}, uses=0, maxlevel=4},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_mcl_toollike_wield = true,
|
|
|
|
_mcl_diggroups = {
|
2023-12-25 18:56:50 +01:00
|
|
|
pickaxey = { speed = 12, level = 5, uses = 0 }
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
|
|
|
on_place = hammer_on_place,
|
|
|
|
on_secondary_use = hammer_on_place,
|
|
|
|
})
|
|
|
|
|
2024-01-22 16:18:52 +01:00
|
|
|
minetest.register_alias("exchangeclone:dark_matter_hammer", "exchangeclone:dark_matter_hammer_3x3")
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
minetest.register_tool("exchangeclone:red_matter_hammer", {
|
2023-11-19 01:48:35 +01:00
|
|
|
description = S("Red Matter Hammer").."\n"..S("Single node mode"),
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_image = "exchangeclone_red_matter_hammer.png",
|
|
|
|
inventory_image = "exchangeclone_red_matter_hammer.png",
|
2023-12-25 18:56:50 +01:00
|
|
|
groups = { tool=1, hammer=1, dig_speed_class=6, enchantability=0, red_matter_hammer = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_scale = exchangeclone.wield_scale,
|
|
|
|
tool_capabilities = {
|
|
|
|
-- 1/1.2
|
|
|
|
full_punch_interval = 0.3,
|
2023-10-30 23:42:11 +01:00
|
|
|
max_drop_level=7,
|
2023-06-21 23:45:22 +02:00
|
|
|
damage_groups = {fleshy=9},
|
|
|
|
punch_attack_uses = 0,
|
|
|
|
groupcaps={
|
|
|
|
cracky = {times={[1]=1, [2]=0.5, [3]=0.2}, uses=0, maxlevel=5},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
_mcl_toollike_wield = true,
|
|
|
|
_mcl_diggroups = {
|
2023-12-25 18:56:50 +01:00
|
|
|
pickaxey = { speed = 19, level = 6, uses = 0 }
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
|
|
|
on_place = hammer_on_place,
|
|
|
|
on_secondary_use = hammer_on_place,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_tool("exchangeclone:red_matter_hammer_3x3", {
|
2023-11-19 01:48:35 +01:00
|
|
|
description = S("Red Matter Hammer\n3x3 mode"),
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_image = "exchangeclone_red_matter_hammer.png",
|
|
|
|
inventory_image = "exchangeclone_red_matter_hammer.png",
|
2023-12-25 18:56:50 +01:00
|
|
|
groups = { tool=1, hammer=1, dig_speed_class=6, enchantability=0, red_matter_hammer = 1, not_in_creative_inventory = 1, disable_repair = 1, fire_immune = 1, exchangeclone_upgradable = 1},
|
2023-06-21 23:45:22 +02:00
|
|
|
wield_scale = exchangeclone.wield_scale,
|
|
|
|
tool_capabilities = {
|
|
|
|
-- 1/1.2
|
|
|
|
full_punch_interval = 0.3,
|
2023-10-30 23:42:11 +01:00
|
|
|
max_drop_level=7,
|
2023-06-21 23:45:22 +02:00
|
|
|
damage_groups = {fleshy=9},
|
|
|
|
punch_attack_uses = 0,
|
|
|
|
groupcaps={
|
|
|
|
cracky = {times={[1]=1.25, [2]=0.6, [3]=0.3}, uses=0, maxlevel=5},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
sound = { breaks = "default_tool_breaks" },
|
|
|
|
_mcl_toollike_wield = true,
|
|
|
|
_mcl_diggroups = {
|
2023-12-25 18:56:50 +01:00
|
|
|
pickaxey = { speed = 14, level = 6, uses = 0 }
|
2023-06-21 23:45:22 +02:00
|
|
|
},
|
|
|
|
on_place = hammer_on_place,
|
|
|
|
on_secondary_use = hammer_on_place,
|
|
|
|
})
|
|
|
|
|
2023-12-18 23:57:30 +01:00
|
|
|
exchangeclone.register_alias("exchangeclone:red_matter_hammer", "exchangeclone:red_matter_hammer_3x3")
|
2023-11-19 01:48:35 +01:00
|
|
|
|
2023-06-21 23:45:22 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:dark_matter_hammer",
|
|
|
|
recipe = {
|
2023-11-10 03:35:23 +01:00
|
|
|
{"exchangeclone:dark_matter", exchangeclone.itemstrings.diamond, "exchangeclone:dark_matter"},
|
|
|
|
{"", exchangeclone.itemstrings.diamond, ""},
|
|
|
|
{"", exchangeclone.itemstrings.diamond, ""}
|
2023-06-21 23:45:22 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "exchangeclone:red_matter_hammer",
|
|
|
|
recipe = {
|
|
|
|
{"exchangeclone:red_matter", "exchangeclone:dark_matter", "exchangeclone:red_matter"},
|
|
|
|
{"", "group:dark_matter_hammer", ""},
|
|
|
|
{"", "exchangeclone:dark_matter", ""}
|
|
|
|
}
|
|
|
|
})
|