Fix conversion of cart inventories to mod storage without duplicating items

This commit is contained in:
teknomunk 2024-12-28 16:35:48 -06:00 committed by the-real-herowl
parent a694675b87
commit bf3b98021f

View file

@ -178,6 +178,13 @@ function DEFAULT_CART_DEF:on_activate(staticdata, dtime_s)
local data = minetest.deserialize(staticdata) or {} local data = minetest.deserialize(staticdata) or {}
if not data.uuid then if not data.uuid then
data.uuid = mcl_util.assign_uuid(self.object) data.uuid = mcl_util.assign_uuid(self.object)
if data._items then
data.inventory = data._items
data._items = nil
data._inv_id = nil
data._inv_size = nil
end
end end
self._seq = data.seq or 1 self._seq = data.seq or 1
@ -283,6 +290,9 @@ function DEFAULT_CART_DEF:on_step(dtime)
staticdata = make_staticdata() staticdata = make_staticdata()
self._staticdata = staticdata self._staticdata = staticdata
end end
if self._items then
self._items = nil
end
-- Update entity position -- Update entity position
local pos = mod.get_cart_position(staticdata) local pos = mod.get_cart_position(staticdata)