Skip to content

Commit

Permalink
Categories: Remove not_in_creative_inventory items
Browse files Browse the repository at this point in the history
`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 <mk939@ymail.com>
  • Loading branch information
Niklp09 and SmallJoker committed Mar 23, 2024
1 parent b5de18b commit 2c9449b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2c9449b

Please sign in to comment.