From 9b99ce71e6b548bc8e3459fd312a26bc0de17f64 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Mon, 23 Dec 2024 21:41:59 -0500 Subject: [PATCH] Populate item groups in correct order (#813) * Populate item groups in correct order * Removed var --- .../main/java/dev/emi/emi/registry/EmiStackList.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xplat/src/main/java/dev/emi/emi/registry/EmiStackList.java b/xplat/src/main/java/dev/emi/emi/registry/EmiStackList.java index 3ef6030d..afc1ef57 100644 --- a/xplat/src/main/java/dev/emi/emi/registry/EmiStackList.java +++ b/xplat/src/main/java/dev/emi/emi/registry/EmiStackList.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Consumer; import java.util.function.Predicate; import java.util.function.Supplier; @@ -82,7 +83,7 @@ public static void reload() { EmiLog.info("Reloading item groups on client thread..."); Map> itemGroupToStacksMap = client.submit(() -> { Map> map = new Reference2ReferenceOpenHashMap<>(); - for (ItemGroup group : ItemGroups.getGroups()) { + Consumer itemGroupConsumer = group -> { String groupName = "null"; try { groupName = group.getDisplayName().toString(); @@ -92,7 +93,12 @@ public static void reload() { EmiLog.error("Creative item group " + groupName + " threw while EMI was attempting to construct the index, items may be missing."); EmiLog.error(e); } - } + }; + List itemGroups = ItemGroups.getGroups(); + // Category item groups must be updated before non-category ones, otherwise the search group will + // read outdated item lists + itemGroups.stream().filter(g -> g.getType() == ItemGroup.Type.CATEGORY).forEach(itemGroupConsumer); + itemGroups.stream().filter(g -> g.getType() != ItemGroup.Type.CATEGORY).forEach(itemGroupConsumer); return map; }).join(); EmiLog.info("Reloading item groups on client thread took " + (System.currentTimeMillis() - groupReloadStart) + "ms");