mirror of
https://git.phreedom.club/localhost_frssoft/fediauth.git
synced 2024-11-17 13:42:38 +00:00
improve position lock
This commit is contained in:
parent
0458d121b8
commit
9bb4c873c9
11
join.lua
11
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
|
||||
|
|
Loading…
Reference in a new issue