From 2c9449b6e796c5a4bcf832b10595c5a78e237dc6 Mon Sep 17 00:00:00 2001 From: Niklp Date: Mon, 18 Mar 2024 15:08:31 +0100 Subject: [PATCH] Categories: Remove `not_in_creative_inventory` items `unified_inventory.is_itemdef_listable` already prevents such items being listed. They are not needed, thus removing them from the categories in the first place does make sense. Co-authored-by: SmallJoker --- api.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/api.lua b/api.lua index 7ab5d66..604d49e 100644 --- a/api.lua +++ b/api.lua @@ -187,8 +187,9 @@ minetest.after(0.01, function() -- Remove unknown items from all categories local total_removed = 0 for cat_name, cat_def in pairs(ui.registered_category_items) do - for itemname, exists in pairs(cat_def) do - if exists and not minetest.registered_items[itemname] then + for itemname, _ in pairs(cat_def) do + local idef = minetest.registered_items[itemname] + if not idef then total_removed = total_removed + 1 --[[ -- For analysis @@ -197,12 +198,21 @@ minetest.after(0.01, function() .. "'. Reason: item not registered") ]] cat_def[itemname] = nil + elseif not ui.is_itemdef_listable(idef) then + total_removed = total_removed + 1 + --[[ + -- For analysis + minetest.log("warning", "[unified_inventory] Removed item '" + .. itemname .. "' from category '" .. cat_name + .. "'. Reason: item is in 'not_in_creative_inventory' group") + ]] + cat_def[itemname] = nil end end end if total_removed > 0 then minetest.log("info", "[unified_inventory] Removed " .. total_removed .. - " unknown items from the categories.") + " items from the categories.") end for _, callback in ipairs(ui.initialized_callbacks) do