Skip to content

Commit

Permalink
Populate item groups in correct order (#813)
Browse files Browse the repository at this point in the history
* Populate item groups in correct order

* Removed var
  • Loading branch information
embeddedt authored Dec 24, 2024
1 parent 8212af8 commit 9b99ce7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions xplat/src/main/java/dev/emi/emi/registry/EmiStackList.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -82,7 +83,7 @@ public static void reload() {
EmiLog.info("Reloading item groups on client thread...");
Map<ItemGroup, Collection<ItemStack>> itemGroupToStacksMap = client.submit(() -> {
Map<ItemGroup, Collection<ItemStack>> map = new Reference2ReferenceOpenHashMap<>();
for (ItemGroup group : ItemGroups.getGroups()) {
Consumer<ItemGroup> itemGroupConsumer = group -> {
String groupName = "null";
try {
groupName = group.getDisplayName().toString();
Expand All @@ -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<ItemGroup> 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");
Expand Down

0 comments on commit 9b99ce7

Please sign in to comment.