mirror of
https://git.phreedom.club/localhost_frssoft/fediauth
synced 2025-03-21 17:11:23 +00:00
improve position lock
This commit is contained in:
parent
0458d121b8
commit
9bb4c873c9
1 changed files with 7 additions and 4 deletions
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
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local playername = player:get_player_name()
|
local playername = player:get_player_name()
|
||||||
local playerpos = player:get_pos()
|
local playerpos = player:get_pos()
|
||||||
|
local current_vel = player:get_velocity()
|
||||||
if fediauth_sessions[playername] ~= nil then
|
if fediauth_sessions[playername] ~= nil then
|
||||||
if playerpos ~= playerpos_stor[playername] then -- position lock, stupid, but works as possible
|
if playerpos ~= playerpos_stor[playername] then -- position lock, stupid, but works as possible
|
||||||
-- maybe compatible with others mods who override physics
|
-- 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:
|
-- Why not just kick when move? Because:
|
||||||
-- - if you joined and fall from sky without fly privege
|
-- - if you joined and fall from sky without fly privege
|
||||||
-- - if your position on slope and etc...
|
-- - if your position on slope and etc...
|
||||||
-- Why not just use physics override? Because
|
-- Why not just use physics override? Because
|
||||||
-- - It not work with mod like flyspeed
|
-- - 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,
|
-- prevent high speed glitches as possible
|
||||||
z = (playerpos_stor[playername].z - playerpos.z) * 2})
|
player:add_velocity({x = current_vel.x * -1,
|
||||||
|
y = current_vel.y * -1,
|
||||||
|
z = current_vel.z * -1})
|
||||||
player:set_pos(playerpos_stor[playername])
|
player:set_pos(playerpos_stor[playername])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue