From 9b349a16845c74ddaeff04782fda898d4618739b Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 18 Feb 2021 09:28:12 +0100 Subject: [PATCH] More flexible wield rotation determination --- mods/ITEMS/mcl_armor/armor.lua | 7 ++++--- mods/ITEMS/mcl_core/craftitems.lua | 1 + mods/ITEMS/mcl_farming/hoes.lua | 5 +++++ mods/ITEMS/mcl_fishing/init.lua | 1 + mods/ITEMS/mcl_mobitems/init.lua | 3 ++- mods/ITEMS/mcl_tools/init.lua | 21 +++++++++++++++++++++ 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_armor/armor.lua b/mods/ITEMS/mcl_armor/armor.lua index 359282a877..f1f7f37599 100644 --- a/mods/ITEMS/mcl_armor/armor.lua +++ b/mods/ITEMS/mcl_armor/armor.lua @@ -98,10 +98,11 @@ armor.update_player_visuals = function(self, player) return end - local player_holding = player:get_wielded_item():get_name() - if string.find(player_holding,"mcl_tools:") or player_holding == "mcl_mobitems:bone" or player_holding == "mcl_fishing:fishing_rod" then + local wielditem = player:get_wielded_item() + local def = wielditem:get_definition() + if def and def._mcl_toollike_wield then player:set_bone_position("Wield_Item", vector.new(0,3.9,1.3), vector.new(90,0,0)) - elseif string.find(player_holding, "mcl_bows:bow") then + elseif string.find(wielditem:get_name(), "mcl_bows:bow") then player:set_bone_position("Wield_Item", vector.new(.5,4.5,-1.6), vector.new(90,0,20)) else player:set_bone_position("Wield_Item", vector.new(-1.5,4.9,1.8), vector.new(135,0,90)) diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 7cffcb7850..2428bb5ea3 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -13,6 +13,7 @@ minetest.register_craftitem("mcl_core:stick", { inventory_image = "default_stick.png", stack_max = 64, groups = { craftitem=1, stick=1 }, + _mcl_toollike_wield = true, }) minetest.register_craftitem("mcl_core:paper", { diff --git a/mods/ITEMS/mcl_farming/hoes.lua b/mods/ITEMS/mcl_farming/hoes.lua index 3f4f9080d9..5a383d78a7 100644 --- a/mods/ITEMS/mcl_farming/hoes.lua +++ b/mods/ITEMS/mcl_farming/hoes.lua @@ -77,6 +77,7 @@ minetest.register_tool("mcl_farming:hoe_wood", { punch_attack_uses = uses.wood, }, _repair_material = "group:wood", + _mcl_toollike_wield = true, }) minetest.register_craft({ @@ -116,6 +117,7 @@ minetest.register_tool("mcl_farming:hoe_stone", { punch_attack_uses = uses.stone, }, _repair_material = "mcl_core:cobble", + _mcl_toollike_wield = true, }) minetest.register_craft({ @@ -151,6 +153,7 @@ minetest.register_tool("mcl_farming:hoe_iron", { punch_attack_uses = uses.iron, }, _repair_material = "mcl_core:iron_ingot", + _mcl_toollike_wield = true, }) minetest.register_craft({ @@ -192,6 +195,7 @@ minetest.register_tool("mcl_farming:hoe_gold", { punch_attack_uses = uses.gold, }, _repair_material = "mcl_core:gold_ingot", + _mcl_toollike_wield = true, }) minetest.register_craft({ @@ -235,6 +239,7 @@ minetest.register_tool("mcl_farming:hoe_diamond", { punch_attack_uses = uses.diamond, }, _repair_material = "mcl_core:diamond", + _mcl_toollike_wield = true, }) minetest.register_craft({ diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index df76efcbd3..1ff56c2773 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -348,6 +348,7 @@ minetest.register_tool("mcl_fishing:fishing_rod", { on_secondary_use = fish, sound = { breaks = "default_tool_breaks" }, _mcl_uses = 65, + _mcl_toollike_wield = true, }) minetest.register_craft({ diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 4e7eabc9ee..650e40ac3e 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -178,6 +178,7 @@ minetest.register_craftitem("mcl_mobitems:bone", { inventory_image = "mcl_mobitems_bone.png", stack_max = 64, groups = { craftitem=1 }, + _mcl_toollike_wield = true, }) minetest.register_craftitem("mcl_mobitems:string",{ @@ -323,9 +324,9 @@ minetest.register_tool("mcl_mobitems:carrot_on_a_stick", { wield_image = "mcl_mobitems_carrot_on_a_stick.png", inventory_image = "mcl_mobitems_carrot_on_a_stick.png", groups = { transport = 1 }, + _mcl_toollike_wield = true, }) - ----------- -- Crafting ----------- diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 91aacc287c..b022bacd80 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -94,6 +94,7 @@ minetest.register_tool("mcl_tools:pick_wood", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "group:wood", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:pick_stone", { description = S("Stone Pickaxe"), @@ -113,6 +114,7 @@ minetest.register_tool("mcl_tools:pick_stone", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:cobble", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:pick_iron", { description = S("Iron Pickaxe"), @@ -132,6 +134,7 @@ minetest.register_tool("mcl_tools:pick_iron", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:iron_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:pick_gold", { description = S("Golden Pickaxe"), @@ -151,6 +154,7 @@ minetest.register_tool("mcl_tools:pick_gold", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:gold_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:pick_diamond", { description = S("Diamond Pickaxe"), @@ -170,6 +174,7 @@ minetest.register_tool("mcl_tools:pick_diamond", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:diamond", + _mcl_toollike_wield = true, }) local get_shovel_dig_group = function(itemstack) @@ -292,6 +297,7 @@ minetest.register_tool("mcl_tools:shovel_wood", { on_place = make_grass_path, sound = { breaks = "default_tool_breaks" }, _repair_material = "group:wood", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:shovel_stone", { description = S("Stone Shovel"), @@ -312,6 +318,7 @@ minetest.register_tool("mcl_tools:shovel_stone", { on_place = make_grass_path, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:cobble", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:shovel_iron", { description = S("Iron Shovel"), @@ -332,6 +339,7 @@ minetest.register_tool("mcl_tools:shovel_iron", { on_place = make_grass_path, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:iron_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:shovel_gold", { description = S("Golden Shovel"), @@ -352,6 +360,7 @@ minetest.register_tool("mcl_tools:shovel_gold", { on_place = make_grass_path, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:gold_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:shovel_diamond", { description = S("Diamond Shovel"), @@ -372,6 +381,7 @@ minetest.register_tool("mcl_tools:shovel_diamond", { on_place = make_grass_path, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:diamond", + _mcl_toollike_wield = true, }) -- Axes @@ -393,6 +403,7 @@ minetest.register_tool("mcl_tools:axe_wood", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "group:wood", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:axe_stone", { description = S("Stone Axe"), @@ -411,6 +422,7 @@ minetest.register_tool("mcl_tools:axe_stone", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:cobble", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:axe_iron", { description = S("Iron Axe"), @@ -430,6 +442,7 @@ minetest.register_tool("mcl_tools:axe_iron", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:iron_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:axe_gold", { description = S("Golden Axe"), @@ -448,6 +461,7 @@ minetest.register_tool("mcl_tools:axe_gold", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:gold_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:axe_diamond", { description = S("Diamond Axe"), @@ -466,6 +480,7 @@ minetest.register_tool("mcl_tools:axe_diamond", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:diamond", + _mcl_toollike_wield = true, }) -- Swords @@ -488,6 +503,7 @@ minetest.register_tool("mcl_tools:sword_wood", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "group:wood", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:sword_stone", { description = S("Stone Sword"), @@ -507,6 +523,7 @@ minetest.register_tool("mcl_tools:sword_stone", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:cobble", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:sword_iron", { description = S("Iron Sword"), @@ -526,6 +543,7 @@ minetest.register_tool("mcl_tools:sword_iron", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:iron_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:sword_gold", { description = S("Golden Sword"), @@ -545,6 +563,7 @@ minetest.register_tool("mcl_tools:sword_gold", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:gold_ingot", + _mcl_toollike_wield = true, }) minetest.register_tool("mcl_tools:sword_diamond", { description = S("Diamond Sword"), @@ -564,6 +583,7 @@ minetest.register_tool("mcl_tools:sword_diamond", { }, sound = { breaks = "default_tool_breaks" }, _repair_material = "mcl_core:diamond", + _mcl_toollike_wield = true, }) --Shears @@ -585,6 +605,7 @@ minetest.register_tool("mcl_tools:shears", { }, on_place = carve_pumpkin, sound = { breaks = "default_tool_breaks" }, + _mcl_toollike_wield = true, })