From 95cd45afbb282ac7d9a734385c059e6312a5852a Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sat, 27 Apr 2024 18:01:32 +0200 Subject: [PATCH] Added hammers --- mods/ENTITIES/mcl_mobs/combat.lua | 1 + mods/ITEMS/mcl_core/nodes_glass.lua | 2 +- mods/ITEMS/mcl_enchanting/enchantments.lua | 3 +- mods/ITEMS/mcl_tools/init.lua | 4 + mods/ITEMS/mcl_weaponry/init.lua | 204 +++++++++++++++++++++ mods/ITEMS/mcl_weaponry/mod.conf | 3 + textures/vl_tool_diamondhammer.png | Bin 0 -> 189 bytes textures/vl_tool_diamondspear.png | Bin 0 -> 183 bytes textures/vl_tool_goldhammer.png | Bin 0 -> 213 bytes textures/vl_tool_goldspear.png | Bin 0 -> 157 bytes textures/vl_tool_netheritehammer.png | Bin 0 -> 255 bytes textures/vl_tool_netheritespear.png | Bin 0 -> 201 bytes textures/vl_tool_steelhammer.png | Bin 0 -> 210 bytes textures/vl_tool_steelspear.png | Bin 0 -> 171 bytes textures/vl_tool_stonehammer.png | Bin 0 -> 228 bytes textures/vl_tool_stonespear.png | Bin 0 -> 144 bytes textures/vl_tool_woodhammer.png | Bin 0 -> 215 bytes textures/vl_tool_woodspear.png | Bin 0 -> 156 bytes 18 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 mods/ITEMS/mcl_weaponry/init.lua create mode 100644 mods/ITEMS/mcl_weaponry/mod.conf create mode 100644 textures/vl_tool_diamondhammer.png create mode 100644 textures/vl_tool_diamondspear.png create mode 100644 textures/vl_tool_goldhammer.png create mode 100644 textures/vl_tool_goldspear.png create mode 100644 textures/vl_tool_netheritehammer.png create mode 100644 textures/vl_tool_netheritespear.png create mode 100644 textures/vl_tool_steelhammer.png create mode 100644 textures/vl_tool_steelspear.png create mode 100644 textures/vl_tool_stonehammer.png create mode 100644 textures/vl_tool_stonespear.png create mode 100644 textures/vl_tool_woodhammer.png create mode 100644 textures/vl_tool_woodspear.png diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index d9df817e4..4071f476a 100644 --- a/mods/ENTITIES/mcl_mobs/combat.lua +++ b/mods/ENTITIES/mcl_mobs/combat.lua @@ -733,6 +733,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir) if hitter and is_player then local wielditem = hitter:get_wielded_item() kb = kb + 9 * mcl_enchanting.get_enchantment(wielditem, "knockback") + kb = kb + 9 * minetest.get_item_group(wielditem:get_name(), "hammer") -- add player velocity to mob knockback local hv = hitter:get_velocity() local dir_dot = (hv.x * dir.x) + (hv.z * dir.z) diff --git a/mods/ITEMS/mcl_core/nodes_glass.lua b/mods/ITEMS/mcl_core/nodes_glass.lua index 8b3aea689..89eda2a1d 100644 --- a/mods/ITEMS/mcl_core/nodes_glass.lua +++ b/mods/ITEMS/mcl_core/nodes_glass.lua @@ -12,7 +12,7 @@ minetest.register_node("mcl_core:glass", { paramtype2 = "glasslikeliquidlevel", sunlight_propagates = true, stack_max = 64, - groups = {handy=1, glass=1, building_block=1, material_glass=1}, + groups = {handy=1, glass=1, building_block=1, material_glass=1, crushable=1}, sounds = mcl_sounds.node_sound_glass_defaults(), drop = "", _mcl_blast_resistance = 0.3, diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index 379a18e07..066e75700 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -284,7 +284,8 @@ function minetest.calculate_knockback(player, hitter, time_from_last_punch, tool local wielditem = hitter:get_wielded_item() --knockback = knockback + 3 * mcl_enchanting.get_enchantment(wielditem, "knockback") local enchant = mcl_enchanting.get_enchantment(wielditem, "knockback") - knockback = knockback + 3.22 * enchant + local hammer = minetest.get_item_group(wielditem:get_name(), "hammer") + knockback = knockback + 3.22 * enchant + 3.22 * hammer -- add vertical lift to knockback local v = player:get_velocity() local added_v = 0 diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 266adc6fc..5df90fba8 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -22,9 +22,13 @@ dig_speed_class group: -- Help texts local pickaxe_longdesc = S("Pickaxes are mining tools to mine hard blocks, such as stone. A pickaxe can also be used as weapon, but it is rather inefficient.") local axe_longdesc = S("An axe is your tool of choice to cut down trees, wood-based blocks and other blocks. Axes deal a lot of damage as well, but they are rather slow.") + local sword_longdesc = S("Swords are great in melee combat, as they are fast, deal high damage and can endure countless battles. Swords can also be used to cut down a few particular blocks, such as cobwebs.") +local sword_use = S("To slash multiple enemies, hold the sword in your hand, then use (rightclick) an enemy.") + local shovel_longdesc = S("Shovels are tools for digging coarse blocks, such as dirt, sand and gravel. They can also be used to turn grass blocks to grass paths. Shovels can be used as weapons, but they are very weak.") local shovel_use = S("To turn a grass block into a grass path, hold the shovel in your hand, then use (rightclick) the top or side of a grass block. This only works when there's air above the grass block.") + local shears_longdesc = S("Shears are tools to shear sheep and to mine a few block types. Shears are a special mining tool and can be used to obtain the original item from grass, leaves and similar blocks that require cutting.") local shears_use = S("To shear sheep or carve faceless pumpkins, use the “place” key on them. Faces can only be carved at the side of faceless pumpkins. Mining works as usual, but the drops are different for a few blocks.") diff --git a/mods/ITEMS/mcl_weaponry/init.lua b/mods/ITEMS/mcl_weaponry/init.lua new file mode 100644 index 000000000..a219d4032 --- /dev/null +++ b/mods/ITEMS/mcl_weaponry/init.lua @@ -0,0 +1,204 @@ +local modname = minetest.get_current_modname() +local modpath = minetest.get_modpath(modname) +local S = minetest.get_translator(modname) + + +local hammer_tt = S("Can crush blocks") .. "\n" .. S("Increased knockback") +local hammer_longdesc = S("Hammers are great in melee combat, as they deal high damage with increased knockback and can endure countless battles. Hammers can also be used to crush things.") +local hammer_use = S("To crush a block, hold the hammer in your hand, then use (rightclick) the block. This only works with some blocks.") + +local spear_longdesc = S("Spears are great in melee combat, as they have an increased reach. They can also be thrown.") +local spear_use = S("To throw a spear, hold it in your hand, then hold use (rightclick) in the air.") + +local wield_scale = mcl_vars.tool_wield_scale + +local function crush(pos) + if pos == nil then + return false + end + local node = minetest.get_node(pos) + local name = node.name + if minetest.get_item_group(name, "crushable") == 2 then + node.name = minetest.registered_nodes[name]._mcl_crushed_into + if node.name then + minetest.set_node(pos, node) + minetest.sound_play("default_dig_cracky", { pos = pos, gain = 0.5 }, true) + return true + end + elseif minetest.get_item_group(name, "crushable") == 1 then + minetest.set_node(pos, {name="air"}) + minetest.sound_play(mcl_sounds.node_sound_glass_defaults().dug, { pos = pos, gain = 0.5 }, true) + return true + end + return false +end + +local hammer_on_place = function(wear_divisor) + return function(itemstack, user, pointed_thing) + -- Call on_rightclick if the pointed node defines it + local node = minetest.get_node(pointed_thing.under) + if user and not user:get_player_control().sneak then + if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then + return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack + end + end + + if minetest.is_protected(pointed_thing.under, user:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) + return itemstack + end + + if crush(pointed_thing.under) then + if not minetest.is_creative_enabled(user:get_player_name()) then + itemstack:add_wear(65535/wear_divisor) + end + return itemstack + end + end +end + +local uses = { + wood = 60, + stone = 132, + iron = 251, + gold = 33, + diamond = 1562, + netherite = 2031, +} + +--Hammers +minetest.register_tool("mcl_weaponry:hammer_wood", { + description = S("Wooden Hammer"), + _tt_help = hammer_tt, + _doc_items_longdesc = hammer_longdesc, + _doc_items_usagehelp = hammer_use, + _doc_items_hidden = false, + inventory_image = "vl_tool_woodhammer.png", + wield_scale = wield_scale, + on_place = hammer_on_place(uses.wood), + groups = { weapon=1, hammer=1, dig_speed_class=2, enchantability=15 }, + tool_capabilities = { + full_punch_interval = 1.2, + max_drop_level=1, + damage_groups = {fleshy=4}, + punch_attack_uses = 60, + }, + sound = { breaks = "default_tool_breaks" }, + _repair_material = "group:wood", + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 2, level = 1, uses = 30 } + }, +}) +minetest.register_tool("mcl_weaponry:hammer_stone", { + description = S("Stone Hammer"), + _tt_help = hammer_tt, + _doc_items_longdesc = hammer_longdesc, + _doc_items_usagehelp = hammer_use, + inventory_image = "vl_tool_stonehammer.png", + wield_scale = wield_scale, + on_place = hammer_on_place(uses.stone), + groups = { weapon=1, hammer=1, dig_speed_class=2, enchantability=5 }, + tool_capabilities = { + full_punch_interval = 1.3, + max_drop_level=3, + damage_groups = {fleshy=5}, + punch_attack_uses = 132, + }, + sound = { breaks = "default_tool_breaks" }, + _repair_material = "group:cobble", + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 2, level = 1, uses = 30 } + }, +}) +minetest.register_tool("mcl_weaponry:hammer_iron", { + description = S("Iron Hammer"), + _tt_help = hammer_tt, + _doc_items_longdesc = hammer_longdesc, + _doc_items_usagehelp = hammer_use, + inventory_image = "vl_tool_steelhammer.png", + wield_scale = wield_scale, + on_place = hammer_on_place(uses.iron), + groups = { weapon=1, hammer=1, dig_speed_class=2, enchantability=14 }, + tool_capabilities = { + full_punch_interval = 1.2, + max_drop_level=4, + damage_groups = {fleshy=6}, + punch_attack_uses = 251, + }, + sound = { breaks = "default_tool_breaks" }, + _repair_material = "mcl_core:iron_ingot", + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 2, level = 1, uses = 30 } + }, +}) +minetest.register_tool("mcl_weaponry:hammer_gold", { + description = S("Golden Hammer"), + _tt_help = hammer_tt, + _doc_items_longdesc = hammer_longdesc, + _doc_items_usagehelp = hammer_use, + inventory_image = "vl_tool_goldhammer.png", + wield_scale = wield_scale, + on_place = hammer_on_place(uses.gold), + groups = { weapon=1, hammer=1, dig_speed_class=2, enchantability=22 }, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=2, + damage_groups = {fleshy=5}, + punch_attack_uses = 33, + }, + sound = { breaks = "default_tool_breaks" }, + _repair_material = "mcl_core:gold_ingot", + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 2, level = 1, uses = 30 } + }, +}) +minetest.register_tool("mcl_weaponry:hammer_diamond", { + description = S("Diamond Hammer"), + _tt_help = hammer_tt, + _doc_items_longdesc = hammer_longdesc, + _doc_items_usagehelp = hammer_use, + inventory_image = "vl_tool_diamondhammer.png", + wield_scale = wield_scale, + on_place = hammer_on_place(uses.diamond), + groups = { weapon=1, hammer=1, dig_speed_class=2, enchantability=10 }, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=5, + damage_groups = {fleshy=7}, + punch_attack_uses = 1562, + }, + sound = { breaks = "default_tool_breaks" }, + _repair_material = "mcl_core:diamond", + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 2, level = 1, uses = 30 } + }, + _mcl_upgradable = true, + _mcl_upgrade_item = "mcl_weaponry:hammer_netherite" +}) +minetest.register_tool("mcl_weaponry:hammer_netherite", { + description = S("Netherite Hammer"), + _tt_help = hammer_tt, + _doc_items_longdesc = hammer_longdesc, + _doc_items_usagehelp = hammer_use, + inventory_image = "vl_tool_netheritehammer.png", + wield_scale = wield_scale, + on_place = hammer_on_place(uses.netherite), + groups = { weapon=1, hammer=1, dig_speed_class=2, enchantability=10, fire_immune=1 }, + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=5, + damage_groups = {fleshy=9}, + punch_attack_uses = 2031, + }, + sound = { breaks = "default_tool_breaks" }, + _repair_material = "mcl_nether:netherite_ingot", + _mcl_toollike_wield = true, + _mcl_diggroups = { + pickaxey = { speed = 2, level = 1, uses = 30 } + }, +}) diff --git a/mods/ITEMS/mcl_weaponry/mod.conf b/mods/ITEMS/mcl_weaponry/mod.conf new file mode 100644 index 000000000..f945e425c --- /dev/null +++ b/mods/ITEMS/mcl_weaponry/mod.conf @@ -0,0 +1,3 @@ +name = mcl_weaponry +author = Herowl +depends = mcl_sounds, mcl_init diff --git a/textures/vl_tool_diamondhammer.png b/textures/vl_tool_diamondhammer.png new file mode 100644 index 0000000000000000000000000000000000000000..0c55213e2961303ef4598d8239d7360f467530de GIT binary patch literal 189 zcmV;u07CzXP)r_KMuDEI%4rrQ6p1t?z4=|L`F%^(+$9HlUuku?*YsPJhfD!^cV rroU!Tppm87*4CDM%^*Nh+QtF^z*@;fF9Mz-00000NkvXXu0mjfDFjV9 literal 0 HcmV?d00001 diff --git a/textures/vl_tool_diamondspear.png b/textures/vl_tool_diamondspear.png new file mode 100644 index 0000000000000000000000000000000000000000..b010c659ce6b12e3aa4b1a633d3b02e11c3df5ce GIT binary patch literal 183 zcmV;o07(CdP)A<=#Zxw2mmO=cOV1ai!KD8T#MVU+uSWbeQX0EH1znn9tC>=LpxBYTIS=BgC0{}UVH zF*FkeV4C9`4anD=8)!pk%^<&m0*x$ZgW?sWnW(gl4S?cxT8avJnt=cSO2NWs%Kv<2 P00000NkvXXu0mjf-;Pk% literal 0 HcmV?d00001 diff --git a/textures/vl_tool_goldspear.png b/textures/vl_tool_goldspear.png new file mode 100644 index 0000000000000000000000000000000000000000..addaa62d97ca3ba588201481f7732b7de7aa973b GIT binary patch literal 157 zcmV;O0Al}%P)cWHD3Pui1gcWJ;I>aoQTb1@ z=7|mQ|8oOv;NBohGg;22SaY1C!2sDjlAH}n7-Tyemc~g=nn(Zu`x|^zZOIf(00000 LNkvXXu0mjfPntRD literal 0 HcmV?d00001 diff --git a/textures/vl_tool_netheritehammer.png b/textures/vl_tool_netheritehammer.png new file mode 100644 index 0000000000000000000000000000000000000000..ada016ca2dbe8464162f4194d0f0543e61dab197 GIT binary patch literal 255 zcmVS*#GTbSTA zz}D6ltQll0NFz)$j7?Cpr>EzC9UYzj$YBBtT)djo)D8YOn%ILiV+#|4noG4!|HsIw z|0g*`!Zd?ul2aW;nqdKk&DjJ2D4t=VO;&D$#WT6N6#ySDjYEeOidp~w002ovPDHLk FV1m=+Vo?A9 literal 0 HcmV?d00001 diff --git a/textures/vl_tool_netheritespear.png b/textures/vl_tool_netheritespear.png new file mode 100644 index 0000000000000000000000000000000000000000..e2a08aa1ee03f5ed24d2ce6eb565688efed564f4 GIT binary patch literal 201 zcmV;)05<=LP)lW{@|C(wwGl zfTEcs0McBlZTde(PJL7}%{7DKlx)qgBnnDhpF literal 0 HcmV?d00001 diff --git a/textures/vl_tool_steelspear.png b/textures/vl_tool_steelspear.png new file mode 100644 index 0000000000000000000000000000000000000000..cc5a5c33ad3ccc3e76a714eca52bf910ed26d2ca GIT binary patch literal 171 zcmV;c095~pP)N>h&4p3!{~b-W!5Tp>AW3t2kPBQh$u?7@8QIzNwRs3S8!* zb34Jbqp3D=u7Me{WkxgD_7{(@fN2n)B(H#+4RZm=H6X7M9k3uhZ6LbMcb77P_IMmU@grLo!XhPRabfUtinW)ePX(l?Jsj3+iX!O?% e3pBDd0|5X6x3705S2~yg00007P)jCRsDcW{~DU2U9RUx_us)Cdx37W|-|DO^&A8|F50f z2^IsfNpi`S8O>nZUp&47ra_n_Z@`=la{8?lMw)eN!)n`T&;kgb^@0BHhgCOMv|qM57|MzLmCppmT^2mswsn24ur RrECBI002ovPDHLkV1i>OP>%or literal 0 HcmV?d00001 diff --git a/textures/vl_tool_woodspear.png b/textures/vl_tool_woodspear.png new file mode 100644 index 0000000000000000000000000000000000000000..045741b1d688a72a2d9ff5c54ba76505cf11851b GIT binary patch literal 156 zcmV;N0Av4&P)14v&E#nY`PtD_n{;P`G=pp;Tk{aLd89cT1ju$a6aWAOLu4g}ZGNW!0000< KMNUMnLSTZ*vN)>% literal 0 HcmV?d00001