From 5ca5811bc8a86a38b7721b6c739ff53b3b4e8bfe Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 8 May 2018 15:58:26 +0200 Subject: [PATCH] Refactor how the misc creative category works --- mods/ENTITIES/mobs/api.lua | 2 +- mods/HUD/mcl_inventory/creative.lua | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mobs/api.lua b/mods/ENTITIES/mobs/api.lua index 6d663e156..a59f2fc0c 100644 --- a/mods/ENTITIES/mobs/api.lua +++ b/mods/ENTITIES/mobs/api.lua @@ -3337,7 +3337,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative) local grp = {spawn_egg = 1} -- do NOT add this egg to creative inventory (e.g. dungeon master) - if creative and no_creative == true then + if no_creative == true then grp.not_in_creative_inventory = 1 end diff --git a/mods/HUD/mcl_inventory/creative.lua b/mods/HUD/mcl_inventory/creative.lua index 41bd3bc0d..d76a5c982 100644 --- a/mods/HUD/mcl_inventory/creative.lua +++ b/mods/HUD/mcl_inventory/creative.lua @@ -25,34 +25,46 @@ do local is_weapon_or_armor = function(def) return def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.combat_item or ((def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet or def.groups.horse_armor) and def.groups.non_combat_armor ~= 1) end + -- Is set to true if it was added in any category besides misc + local nonmisc = false if def.groups.building_block then table.insert(inventory_lists["blocks"], name) + nonmisc = true end if def.groups.deco_block then table.insert(inventory_lists["deco"], name) + nonmisc = true end if is_redstone(def) then table.insert(inventory_lists["redstone"], name) + nonmisc = true end if def.groups.transport then table.insert(inventory_lists["rail"], name) + nonmisc = true end if (def.groups.food and not def.groups.brewitem) or def.groups.eatable then table.insert(inventory_lists["food"], name) + nonmisc = true end if is_tool(def) then table.insert(inventory_lists["tools"], name) + nonmisc = true end if is_weapon_or_armor(def) then table.insert(inventory_lists["combat"], name) + nonmisc = true end if def.groups.brewitem then table.insert(inventory_lists["brew"], name) + nonmisc = true end if def.groups.craftitem then table.insert(inventory_lists["matr"], name) + nonmisc = true end - if not def.groups.building_block and not def.groups.deco_block and not is_redstone(def) and not def.groups.transport and not def.groups.food and not def.groups.eatable and not is_tool(def) and not is_weapon_or_armor(def) and not def.groups.craftitem and not def.groups.brewitem then + -- Misc. category is for everything which is not in any other category + if not nonmisc then table.insert(inventory_lists["misc"], name) end