From 8c1444a1a87be030fcdef1e84176044fb3a48e1f Mon Sep 17 00:00:00 2001 From: epCode Date: Thu, 25 Feb 2021 12:06:24 -0800 Subject: [PATCH] Fix Swim toggling --- mods/PLAYER/mcl_player/init.lua | 18 ++++++++---------- mods/PLAYER/mcl_playerplus/init.lua | 5 +---- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index 2fcf5198e..9a822939a 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -158,10 +158,8 @@ minetest.register_globalstep(function(dtime) - -- ask if player should be crawling - local block_in_head = minetest.registered_nodes[mcl_playerinfo[name].node_head] -- ask if player is swiming - local standing_on_water = minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 + local head_in_water = minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 -- ask if player is sprinting local is_sprinting = mcl_sprint.is_sprinting(name) @@ -173,32 +171,32 @@ minetest.register_globalstep(function(dtime) player_anim[name] = nil player_sneak[name] = controls.sneak end - if controls.LMB and not controls.sneak and standing_on_water and is_sprinting == true or block_in_head.walkable and controls.LMB then + if controls.LMB and not controls.sneak and head_in_water and is_sprinting == true then player_set_animation(player, "swim_walk_mine", animation_speed_mod) - elseif not controls.sneak and standing_on_water and is_sprinting == true or block_in_head.walkable then + elseif not controls.sneak and head_in_water and is_sprinting == true then player_set_animation(player, "swim_walk", animation_speed_mod) - elseif is_sprinting == true and controls.LMB and not controls.sneak and not standing_on_water then + elseif is_sprinting == true and controls.LMB and not controls.sneak and not head_in_water then player_set_animation(player, "run_walk_mine", animation_speed_mod) elseif controls.LMB and not controls.sneak then player_set_animation(player, "walk_mine", animation_speed_mod) elseif controls.LMB and controls.sneak and is_sprinting ~= true then player_set_animation(player, "sneak_walk_mine", animation_speed_mod) - elseif is_sprinting == true and not controls.sneak and not standing_on_water then + elseif is_sprinting == true and not controls.sneak and not head_in_water then player_set_animation(player, "run_walk", animation_speed_mod) elseif controls.sneak and not controls.LMB then player_set_animation(player, "sneak_walk", animation_speed_mod) else player_set_animation(player, "walk", animation_speed_mod) end - elseif controls.LMB and not controls.sneak and standing_on_water and is_sprinting == true or controls.LMB and block_in_head.walkable then + elseif controls.LMB and not controls.sneak and head_in_water and is_sprinting == true then player_set_animation(player, "swim_mine") - elseif not controls.LMB and not controls.sneak and standing_on_water and is_sprinting == true then + elseif not controls.LMB and not controls.sneak and head_in_water and is_sprinting == true then player_set_animation(player, "swim_stand") elseif controls.LMB and not controls.sneak then player_set_animation(player, "mine") elseif controls.LMB and controls.sneak then player_set_animation(player, "sneak_mine") - elseif not controls.sneak and standing_on_water and is_sprinting == true then + elseif not controls.sneak and head_in_water and is_sprinting == true then player_set_animation(player, "swim_stand", animation_speed_mod) elseif not controls.sneak then player_set_animation(player, "stand", animation_speed_mod) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 98afa80f3..ef429c4cf 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -42,9 +42,6 @@ minetest.register_globalstep(function(dtime) player_vel_yaw = degrees(minetest.dir_to_yaw(player_velocity)) end - - local node_in_head = minetest.registered_nodes[mcl_playerinfo[name].node_head] - -- 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 player:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(pitch+90,-30,pitch * -1 * .35)) @@ -64,7 +61,7 @@ minetest.register_globalstep(function(dtime) player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.8,0.35}, eye_height = 1.35, nametag_color = { r = 225, b = 225, a = 0, g = 225 }}) -- sneaking body conrols player:set_bone_position("Body_Control", vector.new(0,6.3,0), vector.new(0,0,0)) - elseif minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and player:get_attach() == nil and mcl_sprint.is_sprinting(name) == true or node_in_head and node_in_head.walkable then + elseif minetest.get_item_group(mcl_playerinfo[name].node_head, "water") ~= 0 and player:get_attach() == nil and mcl_sprint.is_sprinting(name) == true then -- set head pitch and yaw when swimming player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch+90-degrees(dir_to_pitch(player_velocity)),yaw - player_vel_yaw * -1,0)) -- sets eye height, and nametag color accordingly