mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-28 05:21:05 +01:00
Fix cart detaching without unregistering from everything
This commit is contained in:
parent
d165e0d2ed
commit
10fd9bb918
1 changed files with 19 additions and 17 deletions
|
@ -21,23 +21,6 @@ local update_cart_orientation = mod.update_cart_orientation
|
||||||
local get_cart_data = mod.get_cart_data
|
local get_cart_data = mod.get_cart_data
|
||||||
local get_cart_position = mod.get_cart_position
|
local get_cart_position = mod.get_cart_position
|
||||||
|
|
||||||
local function detach_minecart(staticdata)
|
|
||||||
staticdata.connected_at = nil
|
|
||||||
|
|
||||||
local luaentity = mcl_util.get_luaentity_from_uuid(staticdata.uuid)
|
|
||||||
if luaentity then
|
|
||||||
luaentity.object:set_velocity(staticdata.dir * staticdata.velocity)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
mod.detach_minecart = detach_minecart
|
|
||||||
|
|
||||||
local function try_detach_minecart(staticdata)
|
|
||||||
if not staticdata or not staticdata.connected_at then return end
|
|
||||||
if not mod:is_rail(staticdata.connected_at) then
|
|
||||||
mcl_debug("Detaching minecart #"..tostring(staticdata.uuid))
|
|
||||||
detach_minecart(staticdata)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function reverse_direction(staticdata)
|
local function reverse_direction(staticdata)
|
||||||
if staticdata.behind or staticdata.ahead then
|
if staticdata.behind or staticdata.ahead then
|
||||||
|
@ -128,6 +111,25 @@ local function handle_cart_node_watches(staticdata, dtime)
|
||||||
staticdata.node_watches = new_watches
|
staticdata.node_watches = new_watches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function detach_minecart(staticdata)
|
||||||
|
handle_cart_leave(staticdata, staticdata.connected_at, staticdata.dir)
|
||||||
|
staticdata.connected_at = nil
|
||||||
|
|
||||||
|
local luaentity = mcl_util.get_luaentity_from_uuid(staticdata.uuid)
|
||||||
|
if luaentity then
|
||||||
|
luaentity.object:set_velocity(staticdata.dir * staticdata.velocity)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mod.detach_minecart = detach_minecart
|
||||||
|
|
||||||
|
local function try_detach_minecart(staticdata)
|
||||||
|
if not staticdata or not staticdata.connected_at then return end
|
||||||
|
if not mod:is_rail(staticdata.connected_at) then
|
||||||
|
mcl_debug("Detaching minecart #"..tostring(staticdata.uuid))
|
||||||
|
detach_minecart(staticdata)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function handle_cart_collision(cart1_staticdata, prev_pos, next_dir)
|
local function handle_cart_collision(cart1_staticdata, prev_pos, next_dir)
|
||||||
if not cart1_staticdata then return end
|
if not cart1_staticdata then return end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue