Refactor how the misc creative category works

This commit is contained in:
Wuzzy 2018-05-08 15:58:26 +02:00
parent b95dbaf3d7
commit 5ca5811bc8
2 changed files with 14 additions and 2 deletions

@ -3337,7 +3337,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
local grp = {spawn_egg = 1} local grp = {spawn_egg = 1}
-- do NOT add this egg to creative inventory (e.g. dungeon master) -- 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 grp.not_in_creative_inventory = 1
end end

@ -25,34 +25,46 @@ do
local is_weapon_or_armor = function(def) 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) 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 end
-- Is set to true if it was added in any category besides misc
local nonmisc = false
if def.groups.building_block then if def.groups.building_block then
table.insert(inventory_lists["blocks"], name) table.insert(inventory_lists["blocks"], name)
nonmisc = true
end end
if def.groups.deco_block then if def.groups.deco_block then
table.insert(inventory_lists["deco"], name) table.insert(inventory_lists["deco"], name)
nonmisc = true
end end
if is_redstone(def) then if is_redstone(def) then
table.insert(inventory_lists["redstone"], name) table.insert(inventory_lists["redstone"], name)
nonmisc = true
end end
if def.groups.transport then if def.groups.transport then
table.insert(inventory_lists["rail"], name) table.insert(inventory_lists["rail"], name)
nonmisc = true
end end
if (def.groups.food and not def.groups.brewitem) or def.groups.eatable then if (def.groups.food and not def.groups.brewitem) or def.groups.eatable then
table.insert(inventory_lists["food"], name) table.insert(inventory_lists["food"], name)
nonmisc = true
end end
if is_tool(def) then if is_tool(def) then
table.insert(inventory_lists["tools"], name) table.insert(inventory_lists["tools"], name)
nonmisc = true
end end
if is_weapon_or_armor(def) then if is_weapon_or_armor(def) then
table.insert(inventory_lists["combat"], name) table.insert(inventory_lists["combat"], name)
nonmisc = true
end end
if def.groups.brewitem then if def.groups.brewitem then
table.insert(inventory_lists["brew"], name) table.insert(inventory_lists["brew"], name)
nonmisc = true
end end
if def.groups.craftitem then if def.groups.craftitem then
table.insert(inventory_lists["matr"], name) table.insert(inventory_lists["matr"], name)
nonmisc = true
end 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) table.insert(inventory_lists["misc"], name)
end end