From f2c6f069d0db2800e23cfb5ea8779073395b859b Mon Sep 17 00:00:00 2001 From: teknomunk Date: Wed, 14 Feb 2024 11:47:42 +0000 Subject: [PATCH] Make minecart always stop at correct location at end of track, fix crash when placing chest minecart after changing how staticdata is handled --- mods/ENTITIES/mcl_minecarts/init.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index 0d03dde86..2b0561636 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -417,11 +417,17 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o if next_dir == dir * -1 then -- TODO: detach the cart if there isn't a stop after the rail staticdata.velocity = 0 - next_pos = vector.round(next_pos) + local next_pos_before_round = vector.copy(next_pos) + next_pos = vector.round(next_pos + dir * 0.5) if DEBUG and self._driver then local node_name = minetest.get_node(next_pos).name - print("Stopping cart on "..node_name.." at "..tostring(next_pos)) + print("Stopping cart on "..node_name.." at "..tostring(next_pos) + .." pos="..tostring(pos) + ..",next_pos="..tostring(next_pos) + ..",next_pos_before_round="..tostring(next_pos_before_round) + ..",distance="..distance + ) end end @@ -707,7 +713,7 @@ local function register_entity(entity_id, mesh, textures, drop, on_rightclick, o end function cart:get_staticdata() - return minetest.serialize(self._staticdata) + return minetest.serialize(self._staticdata or {}) end minetest.register_entity(entity_id, cart)