diff --git a/join.lua b/join.lua index 515d8e4..5469c2c 100644 --- a/join.lua +++ b/join.lua @@ -207,18 +207,21 @@ if minetest.settings:get_bool("fediauth.position_lock", true) then for _,player in pairs(minetest.get_connected_players()) do local playername = player:get_player_name() local playerpos = player:get_pos() + local current_vel = player:get_velocity() if fediauth_sessions[playername] ~= nil then if playerpos ~= playerpos_stor[playername] then -- position lock, stupid, but works as possible -- maybe compatible with others mods who override physics - -- player can't move too far (around 1-2 blocks, default walk speed) + -- player can't move too far (around 0.5-2 blocks) -- Why not just kick when move? Because: -- - if you joined and fall from sky without fly privege -- - if your position on slope and etc... -- Why not just use physics override? Because -- - It not work with mod like flyspeed - player:add_velocity({x = (playerpos_stor[playername].x - playerpos.x) * 2, - y = (playerpos_stor[playername].y - playerpos.y) * 2, - z = (playerpos_stor[playername].z - playerpos.z) * 2}) + + -- prevent high speed glitches as possible + player:add_velocity({x = current_vel.x * -1, + y = current_vel.y * -1, + z = current_vel.z * -1}) player:set_pos(playerpos_stor[playername]) end end