From 4b4d40f158dc7669b814860262a17b3fe397cd9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Sun, 23 May 2021 20:27:42 +0200 Subject: [PATCH] Use register_on_mods_loaded in mcl_inventory This removes the need to include _mcl_autogroup as a dependency for mcl_inventory (which should be avoided) and decreases the likelihood that the code used for populating item tables is executed before all other mods are loaded. --- mods/HUD/mcl_inventory/creative.lua | 9 ++++----- mods/HUD/mcl_inventory/mod.conf | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 1cebed0c..5474d4b2 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -28,10 +28,9 @@ local function replace_enchanted_books(tbl) end end ---[[ Populate all the item tables. We only do this once. Note this mod must be -loaded after _mcl_autogroup for this to work, because it required certain -groups to be set. ]] -do +--[[ Populate all the item tables. We only do this once. Note this code must be +executed after loading all the other mods in order to work. ]] +minetest.register_on_mods_loaded(function() for name,def in pairs(minetest.registered_items) do if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then local is_redstone = function(def) @@ -109,7 +108,7 @@ do table.sort(to_sort) replace_enchanted_books(to_sort) end -end +end) local function filter_item(name, description, lang, filter) local desc diff --git a/mods/HUD/mcl_inventory/mod.conf b/mods/HUD/mcl_inventory/mod.conf index d9b78454..f8b9af2a 100644 --- a/mods/HUD/mcl_inventory/mod.conf +++ b/mods/HUD/mcl_inventory/mod.conf @@ -1,4 +1,4 @@ name = mcl_inventory description = Adds the player inventory and creative inventory. depends = mcl_init, mcl_formspec, mcl_enchanting -optional_depends = mcl_player, _mcl_autogroup, mcl_armor, mcl_brewing, mcl_potions +optional_depends = mcl_player, mcl_armor, mcl_brewing, mcl_potions