Make minecart always stop at correct location at end of track, fix crash when placing chest minecart after changing how staticdata is handled
This commit is contained in:
parent
ce83be4092
commit
5272d3c744
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue