From 0bb99809708bd42586a6a12899f8bbc0f011241e 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 8e3ea94dc..63390da91 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 64fe2ac09..9e91decd4 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -285,7 +285,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 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EuJopAr_~T6BL+^tl#}{eq#*7 zrI@;R-|IK=G-k$qd|`h_Kvs6{|9SJ~{r9|7^ZTy+4n>8t3eFy7jGGiyD%+EsnPh$b zPtNsNv;6G;LmJ=z_bt2ie pFmdV4YuBdLoKO`4Q%6(tr~QS4Q%Yth zGAyyYcKO-<#VgHjsH$Y^^%SvZv+ZnAVRo2xxjE**tdm7%uCo%)E!%(A`NGWw6{^w3 jI&)vYcrjtQBnN}Wk#Ys;wR)*QmoRv``njxgN@xNA-5O2C literal 0 HcmV?d00001 diff --git a/textures/vl_tool_goldhammer.png b/textures/vl_tool_goldhammer.png new file mode 100644 index 0000000000000000000000000000000000000000..d7fcd5cd354d95a7cff8805e0590e9499fb00f94 GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`b39!fLo7}wCnzx0?27sM|LVad z|9PG;%t#a1x9N^Zj>m%Lm;WRDXa9G}X3Jzrl#q6@o|PqR#;`0gykAU0S=wofc!Jcl z5RJh50*jc;Y)?F`Pn`0*KIQ!Z9)?!Iz*&w9``!p`GEuH>U+`>|$ol`n(vJ*Hgjo}2 zJ(l4;aea<-hI9H^h5b!Ty*la5k3^TuT(PB>x8YG~R2Ns}tVRX~uY-ruPyMe+1-g^L M)78&qol`;+0N;*K*8l(j 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 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`DV{ElAr_~T6BLANcE$XZZ#jAC z&#Qz>^#b>m*qcq^5^xOawAk1?_pT&EGrlr~jsBoxC6a7c=KR zxToN49C>b8MDd)(2N`bKOq#>%C6Qt+J?)sM-z*OXhTqaPA-N|-e1Y~cc)I$ztaD0e F0sv2%Iq3iZ 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 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`6FglULo7}wCnyNdkdpkvp18?m zm6qn8>sK!++-vC3SpWZGoZ0`Usj2_Gy*iqC84?%evSzM3)yI-NA+d>xDWTb;$jamM z>SoV`=^dRN6PDe)c1$W%kml)%~WBy z6tgP#m%W=`ZHVz%)8Yh0O_+^jMCqN#Fqdq(==Y&EWc zC6Y@xm&{z@;#7KefrGO5=Cx~ef6j6|aQX7*{e69Wm9rWd7(UP4F8zPqvR^<)GI+ZB KxvXB>Ar_~T6BLAPYCk=&=a{^- z@b9dp31`*&<^T9^OB3+j;ual!`~SRo^Zu8Xl>BSHp^|wljpHO6i`9&O{a?5I)`L=xdJ3M!RTH>lj8B>cFOj@?^UKys4lC&?7ALOpFl~6^nYWFN;q%La V@p9M1ueT literal 0 HcmV?d00001 diff --git a/textures/vl_tool_stonehammer.png b/textures/vl_tool_stonehammer.png new file mode 100644 index 0000000000000000000000000000000000000000..b20b99e45ad9abbd7e8e8cf0a95121ab2f7547d3 GIT binary patch literal 228 zcmV!* zb34Jbqp3D=u7Me{WkxgD_7{(@fN2n)B(H#+4RZm=H6X7M9k3uhZ6LbMcb77P_IMmU@grLo!XhPRabfUtinW)ePX(l?Jsj3+iX!O?% e3pBDd0|5X6x3705S2~yg0000d%}1{r}O&+W#F*PR?SM_4(iYVVdOG_a`pRk$dv#{>6~l tHnWp$b5C5iamkg-JjcekX)Z4-gN0KRQ^Nb}M}bx_c)I$ztaD0e0s!8mH(dY# literal 0 HcmV?d00001 diff --git a/textures/vl_tool_woodhammer.png b/textures/vl_tool_woodhammer.png new file mode 100644 index 0000000000000000000000000000000000000000..c528f1a643bc8658f237385e425996db3487fa37 GIT binary patch literal 215 zcmV;|04V>7P)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 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`$(}BbAr_~T6BL9++;;x==P&x{ zzsYUFvIu|a4bL3dFaKA$?KSaP_VcnP(@AS2S^DzkfB%2