1
0
Fork 0

Tune respawn distance limit

This commit is contained in:
teknomunk 2024-04-09 23:27:49 +00:00
parent d1b5e77ca1
commit fe3e783f6f
2 changed files with 7 additions and 8 deletions

View File

@ -1202,9 +1202,9 @@ function mcl_util.assign_uuid(obj)
assert(obj)
local le = obj:get_luaentity()
if le._uuid then return le._uuid end
if not le._uuid then
le._uuid = mcl_util.gen_uuid()
end
-- Update the cache with this new id
aoid = mcl_util.get_active_object_id(obj)

View File

@ -470,21 +470,20 @@ local function respawn_cart(cart)
local d = vector.distance(player:get_pos(), pos)
if not distance or d < distance then distance = d end
end
if not distance or distance > 115 then return end
if not distance or distance > 90 then return end
print("Respawning cart #"..cart.uuid.." at "..tostring(pos)..",distance="..distance)
print("Respawning cart #"..cart.uuid.." at "..tostring(pos)..",distance="..distance..",node="..minetest.get_node(pos).name)
-- Update sequence so that old cart entities get removed
cart.seq = (cart.seq or 1) + 1
save_cart_data(cart.uuid)
-- Create the new entity
-- Create the new entity and refresh caches
local sd = minetest.serialize({ uuid=cart.uuid, seq=cart.seq })
local entity = minetest.add_entity(pos, cart_type, sd)
local le = entity:get_luaentity()
le._seq = cart.seq
le._uuid = cart.uuid
le._staticdata = cart
mcl_util.assign_uuid(entity)
-- We intentionally don't call the normal hooks because this minecart was already there
end