forked from VoxeLibre/VoxeLibre
Update mount.lua to fix horse riding problem
Previously, horses would continue to move even after the movement key was released. This was because mcl_mobs.drive was returning before stopping the horse. This commit makes mcl_mobs.drive stop the horse before returning.
This commit is contained in:
parent
02cb0818a1
commit
bfc2f073bf
|
@ -258,6 +258,18 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Stop!
|
||||||
|
local s = get_sign(entity.v)
|
||||||
|
|
||||||
|
entity.v = entity.v - 0.02 * s
|
||||||
|
|
||||||
|
if s ~= get_sign(entity.v) then
|
||||||
|
|
||||||
|
entity.object:set_velocity({x = 0, y = 0, z = 0})
|
||||||
|
entity.v = 0
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- if not moving then set animation and return
|
-- if not moving then set animation and return
|
||||||
if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
if entity.v == 0 and velo.x == 0 and velo.y == 0 and velo.z == 0 then
|
||||||
|
|
||||||
|
@ -273,18 +285,6 @@ function mcl_mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
|
||||||
mcl_mobs:set_animation(entity, moving_anim)
|
mcl_mobs:set_animation(entity, moving_anim)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop!
|
|
||||||
local s = get_sign(entity.v)
|
|
||||||
|
|
||||||
entity.v = entity.v - 0.02 * s
|
|
||||||
|
|
||||||
if s ~= get_sign(entity.v) then
|
|
||||||
|
|
||||||
entity.object:set_velocity({x = 0, y = 0, z = 0})
|
|
||||||
entity.v = 0
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- enforce speed limit forward and reverse
|
-- enforce speed limit forward and reverse
|
||||||
local max_spd = entity.max_speed_reverse
|
local max_spd = entity.max_speed_reverse
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue