From fe3e783f6f818be975cae11ee661b37e40430a73 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Tue, 9 Apr 2024 23:27:49 +0000 Subject: [PATCH] Tune respawn distance limit --- mods/CORE/mcl_util/init.lua | 6 +++--- mods/ENTITIES/mcl_minecarts/carts.lua | 9 ++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 7b3127db6..9f8b4f325 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -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 - - le._uuid = mcl_util.gen_uuid() + 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) diff --git a/mods/ENTITIES/mcl_minecarts/carts.lua b/mods/ENTITIES/mcl_minecarts/carts.lua index 78cc552f7..00ee39356 100644 --- a/mods/ENTITIES/mcl_minecarts/carts.lua +++ b/mods/ENTITIES/mcl_minecarts/carts.lua @@ -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