Fix inventory sync

This commit is contained in:
IQuant 2024-05-15 17:39:40 +03:00
parent 3295b0eff0
commit a2d320f007

View file

@ -232,13 +232,11 @@ local function on_world_pre_update_inner()
net.send_host_player_info(player_info)
end
if ctx.events.new_player_just_connected or ctx.events.inventory_maybe_just_changed or GameGetFrameNum() % 5 == 0 then
if ctx.events.new_player_just_connected or inventory_helper.has_inventory_changed(my_player) then
local inventory_state = player_fns.serialize_items(my_player)
if inventory_state ~= nil then
-- GamePrint("Sending updated inventory")
net.send_player_inventory(inventory_state)
end
if ctx.events.new_player_just_connected or ctx.events.inventory_maybe_just_changed or (GameGetFrameNum() % 5 == 0 and inventory_helper.has_inventory_changed(my_player)) then
local inventory_state = player_fns.serialize_items(my_player)
if inventory_state ~= nil then
-- GamePrint("Sending updated inventory")
net.send_player_inventory(inventory_state)
end
end