diff --git a/i4/src/common.lua b/i4/src/common.lua index 34602fa..17cbb7d 100644 --- a/i4/src/common.lua +++ b/i4/src/common.lua @@ -678,7 +678,17 @@ local function update_inv_size(player, data) data.hotbar_len = data.legacy_inventory and 8 or 9 data.inv_size = 4 * data.hotbar_len + local inv = player:get_inventory() + local inv_size = inv:get_size("main") + -- Drop items that can’t fit in new inventory size. + if inv_size > data.inv_size then + sort_inventory(player, data) + for i = data.inv_size + 1, inv_size, 1 do + minetest.item_drop(inv:get_stack("main", i), player, player:get_pos()) + end + end + inv:set_size("main", data.inv_size) player:hud_set_hotbar_itemcount(data.hotbar_len)