From 5a0b7bc131ab60e20fc8f8d2150a58b04833a3be Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 27 Feb 2021 15:07:10 +0100 Subject: [PATCH] Fix usages of player:get_velocity(), closes #1203 --- mods/PLAYER/mcl_player/init.lua | 4 +++- mods/PLAYER/mcl_playerplus/init.lua | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/PLAYER/mcl_player/init.lua b/mods/PLAYER/mcl_player/init.lua index a7b038b4..8cc93e73 100644 --- a/mods/PLAYER/mcl_player/init.lua +++ b/mods/PLAYER/mcl_player/init.lua @@ -163,10 +163,12 @@ minetest.register_globalstep(function(dtime) -- ask if player is sprinting local is_sprinting = mcl_sprint.is_sprinting(name) + local velocity = player:get_velocity() or player:get_player_velocity() + -- Apply animations based on what the player is doing if player:get_hp() == 0 then player_set_animation(player, "lay") - elseif walking and player:get_velocity().x > 0.35 or walking and player:get_velocity().x < -0.35 or walking and player:get_velocity().z > 0.35 or walking and player:get_velocity().z < -0.35 then + elseif walking and velocity.x > 0.35 or walking and velocity.x < -0.35 or walking and velocity.z > 0.35 or walking and velocity.z < -0.35 then if player_sneak[name] ~= controls.sneak then player_anim[name] = nil player_sneak[name] = controls.sneak diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 56a77e30..60eb00c7 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -29,7 +29,7 @@ minetest.register_globalstep(function(dtime) local controls = player:get_player_control() name = player:get_player_name() - local player_velocity = player:get_velocity() + local player_velocity = player:get_velocity() or player:get_player_velocity() -- controls head bone local pitch = degrees(player:get_look_vertical()) * -1 @@ -73,7 +73,7 @@ minetest.register_globalstep(function(dtime) -- sets eye height, and nametag color accordingly player:set_properties({collisionbox = {-0.35,0,-0.35,0.35,1.8,0.35}, eye_height = 1.65, nametag_color = { r = 225, b = 225, a = 225, g = 225 }}) - if player:get_velocity().x > 0.35 or player:get_velocity().z > 0.35 or player:get_velocity().x < -0.35 or player:get_velocity().z < -0.35 then + if player_velocity.x > 0.35 or player_velocity.z > 0.35 or player_velocity.x < -0.35 or player_velocity.z < -0.35 then if player_vel_yaw * -1 - yaw < 90 or player_vel_yaw * -1 - yaw > 270 then -- controls head and Body_Control bones while moving backwards player:set_bone_position("Head", vector.new(0,6.3,0), vector.new(pitch,yaw - player_vel_yaw * -1,0))