mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-23 06:32:25 +01:00
Beds: Preserve player physics (#2789)
This commit is contained in:
parent
ecfebe3c17
commit
6a9cbcad82
@ -61,7 +61,6 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
-- stand up
|
-- stand up
|
||||||
if state ~= nil and not state then
|
if state ~= nil and not state then
|
||||||
local p = beds.pos[name] or nil
|
local p = beds.pos[name] or nil
|
||||||
beds.player[name] = nil
|
|
||||||
beds.bed_position[name] = nil
|
beds.bed_position[name] = nil
|
||||||
-- skip here to prevent sending player specific changes (used for leaving players)
|
-- skip here to prevent sending player specific changes (used for leaving players)
|
||||||
if skip then
|
if skip then
|
||||||
@ -72,10 +71,16 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- physics, eye_offset, etc
|
-- physics, eye_offset, etc
|
||||||
|
local physics_override = assert(beds.player[name].physics_override)
|
||||||
|
beds.player[name] = nil
|
||||||
|
player:set_physics_override({
|
||||||
|
speed = physics_override.speed,
|
||||||
|
jump = physics_override.jump,
|
||||||
|
gravity = physics_override.gravity
|
||||||
|
})
|
||||||
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
player:set_look_horizontal(math.random(1, 180) / 100)
|
player:set_look_horizontal(math.random(1, 180) / 100)
|
||||||
player_api.player_attached[name] = false
|
player_api.player_attached[name] = false
|
||||||
player:set_physics_override({speed = 1, jump = 1, gravity = 1})
|
|
||||||
hud_flags.wielditem = true
|
hud_flags.wielditem = true
|
||||||
player_api.set_animation(player, "stand" , 30)
|
player_api.set_animation(player, "stand" , 30)
|
||||||
|
|
||||||
@ -98,7 +103,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
|||||||
|
|
||||||
beds.pos[name] = pos
|
beds.pos[name] = pos
|
||||||
beds.bed_position[name] = bed_pos
|
beds.bed_position[name] = bed_pos
|
||||||
beds.player[name] = 1
|
beds.player[name] = {physics_override = player:get_physics_override()}
|
||||||
|
|
||||||
-- physics, eye_offset, etc
|
-- physics, eye_offset, etc
|
||||||
player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
|
player:set_eye_offset({x = 0, y = -13, z = 0}, {x = 0, y = 0, z = 0})
|
||||||
|
Loading…
Reference in New Issue
Block a user