1
0
mirror of https://github.com/minetest/minetest_game.git synced 2025-06-30 05:40:24 +02:00

Attachments: Proper data cleanup in callbacks (#2865)

This commit is contained in:
SmallJoker
2021-05-11 21:15:47 +02:00
committed by GitHub
parent 642fde44f1
commit 71ea0c65ea
3 changed files with 21 additions and 24 deletions

View File

@ -12,7 +12,7 @@ function carts:manage_attachment(player, obj)
end
local status = obj ~= nil
local player_name = player:get_player_name()
if player_api.player_attached[player_name] == status then
if obj and player:get_attach() == obj then
return
end
player_api.player_attached[player_name] = status
@ -20,6 +20,10 @@ function carts:manage_attachment(player, obj)
if status then
player:set_attach(obj, "", {x=0, y=-4.5, z=0}, {x=0, y=0, z=0})
player:set_eye_offset({x=0, y=-4, z=0},{x=0, y=-4, z=0})
-- player_api does not update the animation
-- when the player is attached, reset to default animation
player_api.set_animation(player, "stand")
else
player:set_detach()
player:set_eye_offset({x=0, y=0, z=0},{x=0, y=0, z=0})