From 732296aa15590cc2a92311a84ff264a95698aa77 Mon Sep 17 00:00:00 2001 From: Guy Liner Date: Sun, 16 Jan 2022 15:54:49 -0500 Subject: [PATCH] Modified collision detection to be based on velocity vector length rather than if the block you're touching is or is not air --- mods/PLAYER/mcl_playerinfo/init.lua | 7 +++---- mods/PLAYER/mcl_sprint/init.lua | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mods/PLAYER/mcl_playerinfo/init.lua b/mods/PLAYER/mcl_playerinfo/init.lua index 56c03a026..4babc9f42 100644 --- a/mods/PLAYER/mcl_playerinfo/init.lua +++ b/mods/PLAYER/mcl_playerinfo/init.lua @@ -88,14 +88,13 @@ function mcl_playerinfo:collision_detect(pos,player) for placement,coord in pairs(around_player) do local node = minetest.get_node(coord) local distance = vector.distance(pos, coord) + local not_moving = vector.length(player:get_velocity()) < 3 -- How far is the player from the block in the given direction and -- if the block is not air the player is colliding with it - --print(node.name) - --print(distance) - if vector.distance(pos, coord) < too_close and node.name ~= "air" then + if vector.distance(pos, coord) < too_close and not_moving then return false --Should be able to detect when your head is touching a slab - elseif distance < slab_too_close and distance > too_close and placement == "front_ofplayerplus" and node.name ~= "air" then + elseif distance < slab_too_close and distance > too_close and not_moving and placement == "front_ofplayerplus" then return false end end diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 00f319080..8a6a2342d 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -175,7 +175,6 @@ minetest.register_globalstep(function(dtime) --Check if the player should be sprinting if not isNotColliding and ctrl.aux1 and ctrl.up and not ctrl.sneak then - print("uwu") players[playerName]["shouldSprint"] = false elseif isNotColliding and players[playerName]["clientSprint"] or ctrl.aux1 and ctrl.up and not ctrl.sneak then players[playerName]["shouldSprint"] = true