diff --git a/mods/ENTITIES/mcl_mobs/combat.lua b/mods/ENTITIES/mcl_mobs/combat.lua index 608209ee2..550049f65 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 000000000..0c55213e2 Binary files /dev/null and b/textures/vl_tool_diamondhammer.png differ diff --git a/textures/vl_tool_diamondspear.png b/textures/vl_tool_diamondspear.png new file mode 100644 index 000000000..b010c659c Binary files /dev/null and b/textures/vl_tool_diamondspear.png differ diff --git a/textures/vl_tool_goldhammer.png b/textures/vl_tool_goldhammer.png new file mode 100644 index 000000000..d7fcd5cd3 Binary files /dev/null and b/textures/vl_tool_goldhammer.png differ diff --git a/textures/vl_tool_goldspear.png b/textures/vl_tool_goldspear.png new file mode 100644 index 000000000..addaa62d9 Binary files /dev/null and b/textures/vl_tool_goldspear.png differ diff --git a/textures/vl_tool_netheritehammer.png b/textures/vl_tool_netheritehammer.png new file mode 100644 index 000000000..ada016ca2 Binary files /dev/null and b/textures/vl_tool_netheritehammer.png differ diff --git a/textures/vl_tool_netheritespear.png b/textures/vl_tool_netheritespear.png new file mode 100644 index 000000000..e2a08aa1e Binary files /dev/null and b/textures/vl_tool_netheritespear.png differ diff --git a/textures/vl_tool_steelhammer.png b/textures/vl_tool_steelhammer.png new file mode 100644 index 000000000..1ac02ab1f Binary files /dev/null and b/textures/vl_tool_steelhammer.png differ diff --git a/textures/vl_tool_steelspear.png b/textures/vl_tool_steelspear.png new file mode 100644 index 000000000..cc5a5c33a Binary files /dev/null and b/textures/vl_tool_steelspear.png differ diff --git a/textures/vl_tool_stonehammer.png b/textures/vl_tool_stonehammer.png new file mode 100644 index 000000000..b20b99e45 Binary files /dev/null and b/textures/vl_tool_stonehammer.png differ diff --git a/textures/vl_tool_stonespear.png b/textures/vl_tool_stonespear.png new file mode 100644 index 000000000..8d38d7dc7 Binary files /dev/null and b/textures/vl_tool_stonespear.png differ diff --git a/textures/vl_tool_woodhammer.png b/textures/vl_tool_woodhammer.png new file mode 100644 index 000000000..c528f1a64 Binary files /dev/null and b/textures/vl_tool_woodhammer.png differ diff --git a/textures/vl_tool_woodspear.png b/textures/vl_tool_woodspear.png new file mode 100644 index 000000000..045741b1d Binary files /dev/null and b/textures/vl_tool_woodspear.png differ