From 34dbddb40ac7756714ac49cdebce092259e9b2d2 Mon Sep 17 00:00:00 2001 From: iliekprogrammar Date: Sat, 20 Mar 2021 08:42:48 +0800 Subject: [PATCH] Move holding code into mcl_playerplus --- mods/PLAYER/mcl_playerplus/init.lua | 14 ++++++++++++-- mods/PLAYER/wieldview/init.lua | 8 +------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 1f66b344f7..2759ebc30a 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -96,6 +96,8 @@ minetest.register_globalstep(function(dtime) local player_velocity = player:get_velocity() or player:get_player_velocity() + local wielded = player:get_wielded_item() + -- controls head bone local pitch = - degrees(player:get_look_vertical()) local yaw = degrees(player:get_look_horizontal()) @@ -107,13 +109,21 @@ minetest.register_globalstep(function(dtime) player_vel_yaw = limit_vel_yaw(player_vel_yaw, yaw) player_vel_yaws[name] = player_vel_yaw - -- controls right and left arms pitch when shooting a bow or punching - if string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and controls.RMB and not controls.LMB and not controls.up and not controls.down and not controls.left and not controls.right then + -- controls right and left arms pitch when shooting a bow + if string.find(wielded:get_name(), "mcl_bows:bow") and controls.RMB and not controls.LMB and not controls.up and not controls.down and not controls.left and not controls.right then + minetest.chat_send_all("entered 1") player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3.5,5.785,0), vector.new(pitch+90,43,pitch * .35)) + -- when punching elseif controls.LMB and player:get_attach() == nil then + minetest.chat_send_all("entered 2") player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch,0,0)) player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0)) + -- when holding an item. + elseif wielded:get_name() ~= "" then + player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(20,0,0)) + player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0)) + -- resets arms pitch else player:set_bone_position("Arm_Left_Pitch_Control", vector.new(3,5.785,0), vector.new(0,0,0)) player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(0,0,0)) diff --git a/mods/PLAYER/wieldview/init.lua b/mods/PLAYER/wieldview/init.lua index 4db711622b..48f3f99bd9 100644 --- a/mods/PLAYER/wieldview/init.lua +++ b/mods/PLAYER/wieldview/init.lua @@ -114,16 +114,10 @@ minetest.register_entity("wieldview:wieldnode", { -- wield item as cubic if armor.textures[self.wielder].wielditem == "blank.png" then self.object:set_properties({textures = {itemstring}}) - else -- displayed item as flat + else -- wield item as flat self.object:set_properties({textures = {""}}) end - if itemstring == "" then -- holding item - player:set_bone_position("Arm_Right", vector.new(0, 0, 0), vector.new(0, 0, 0)) - else -- empty hands - player:set_bone_position("Arm_Right", vector.new(0, 0, 0), vector.new(20, 0, 0)) - end - self.itemstring = itemstring end else