1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-22 15:00:18 +01:00

Fix deprecated get_player_velocity and set_physics_override calls (#2770)

This commit is contained in:
SmallJoker 2020-11-04 21:42:35 +01:00 committed by GitHub
parent 720d4c8e3f
commit 331bbae058
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -75,7 +75,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
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_api.player_attached[name] = false
player:set_physics_override(1, 1, 1)
player:set_physics_override({speed = 1, jump = 1, gravity = 1})
hud_flags.wielditem = true
player_api.set_animation(player, "stand" , 30)
@ -91,7 +91,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
end
-- Check if player is moving
if vector.length(player:get_player_velocity()) > 0.001 then
if vector.length(player:get_velocity()) > 0.001 then
minetest.chat_send_player(name, S("You have to stop moving before going to bed!"))
return false
end
@ -112,7 +112,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
y = bed_pos.y + 0.07,
z = bed_pos.z + dir.z / 2
}
player:set_physics_override(0, 0, 0)
player:set_physics_override({speed = 0, jump = 0, gravity = 0})
player:set_pos(p)
player_api.player_attached[name] = true
hud_flags.wielditem = false
@ -284,4 +284,3 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end
end)

View File

@ -165,7 +165,7 @@ local function entity_physics(pos, radius, drops)
if obj:is_player() then
local dir = vector.normalize(vector.subtract(obj_pos, pos))
local moveoff = vector.multiply(dir, 2 / dist * radius)
obj:add_player_velocity(moveoff)
obj:add_velocity(moveoff)
obj:set_hp(obj:get_hp() - damage)
else