From 2fa5563408203e2131373f54a1092eeabaff1298 Mon Sep 17 00:00:00 2001 From: slprime <31038811+slprime@users.noreply.github.com> Date: Sat, 8 Nov 2025 09:12:40 +0200 Subject: [PATCH 1/2] Optimizing cross-dimension loading (#806) --- .../java/codechicken/nei/NEIClientConfig.java | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/main/java/codechicken/nei/NEIClientConfig.java b/src/main/java/codechicken/nei/NEIClientConfig.java index adefc4d1..5363c00e 100644 --- a/src/main/java/codechicken/nei/NEIClientConfig.java +++ b/src/main/java/codechicken/nei/NEIClientConfig.java @@ -851,24 +851,27 @@ public class NEIClientConfig { } public static void loadWorld(String worldPath) { + final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath); + final boolean newWorld = !specificDir.exists(); unloadWorld(); setInternalEnabled(true); - if (!worldPath.equals(NEIClientConfig.worldPath)) { + if (!worldPath.equals(NEIClientConfig.worldPath) || newWorld) { NEIClientConfig.worldPath = worldPath; - logger.debug("Loading " + (Minecraft.getMinecraft().isSingleplayer() ? "Local" : "Remote") + " World"); - - final File specificDir = new File(CommonUtils.getMinecraftDir(), "saves/NEI/" + worldPath); - final boolean newWorld = !specificDir.exists(); - if (newWorld) { specificDir.mkdirs(); } world = new ConfigSet(new File(specificDir, "NEI.dat"), new ConfigFile(new File(specificDir, "NEI.cfg"))); + + if (newWorld && Minecraft.getMinecraft().isSingleplayer()) { + world.config.getTag("inventory.cheatmode") + .setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0); + } + bootNEI(); - onWorldLoad(newWorld); + onWorldLoad(); } } @@ -876,7 +879,7 @@ public class NEIClientConfig { return NEIClientConfig.worldPath; } - private static void onWorldLoad(boolean newWorld) { + private static void onWorldLoad() { world.config.setComment( "World based configuration of NEI.\nMost of these options can be changed ingame.\nDeleting any element will restore it to it's default value"); @@ -884,12 +887,6 @@ public class NEIClientConfig { creativeInv = new ItemStack[54]; LayoutManager.searchField.setText(getSearchExpression()); LayoutManager.quantity.setText(Integer.toString(getItemQuantity())); - - if (newWorld && Minecraft.getMinecraft().isSingleplayer()) { - world.config.getTag("inventory.cheatmode") - .setIntValue(NEIClientUtils.mc().playerController.isInCreativeMode() ? 2 : 0); - } - NEIInfo.load(ClientUtils.getWorld()); } @@ -914,12 +911,7 @@ public class NEIClientConfig { SubsetWidget.saveHidden(); FavoriteRecipes.save(); CollapsibleItems.saveStates(); - - if (world != null) { - world.saveNBT(); - NEIClientConfig.worldPath = null; - world = null; - } + world.saveNBT(); } private static final Map keySettings = new HashMap<>(); From 9fd38da2055b769f363e635efe0aad80cf282b0b Mon Sep 17 00:00:00 2001 From: slprime <31038811+slprime@users.noreply.github.com> Date: Sat, 8 Nov 2025 09:18:14 +0200 Subject: [PATCH 2/2] Correctly collapse recipe (#807) --- .../nei/bookmark/RecipeChainDetails.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/codechicken/nei/bookmark/RecipeChainDetails.java b/src/main/java/codechicken/nei/bookmark/RecipeChainDetails.java index 615407ae..e73a68de 100644 --- a/src/main/java/codechicken/nei/bookmark/RecipeChainDetails.java +++ b/src/main/java/codechicken/nei/bookmark/RecipeChainDetails.java @@ -350,22 +350,20 @@ public class RecipeChainDetails { private Set getRecipeParents(RecipeChainMath math, RecipeId recipeId, Set parents, Set visited) { final Set recipeIds = math.preferredItems.entrySet().stream() - .filter( - entry -> entry.getValue() != null && recipeId.equals(entry.getValue().recipeId) - && !visited.contains(entry.getKey().recipeId)) + .filter(entry -> entry.getValue() != null && recipeId.equals(entry.getValue().recipeId)) .map(entry -> entry.getKey().recipeId).collect(Collectors.toSet()); - visited.addAll(recipeIds); - if (recipeIds.isEmpty()) { parents.add(recipeId); } else { for (RecipeId ingrRecipeId : recipeIds) { - if (math.outputRecipes.containsKey(ingrRecipeId)) { - parents.add(ingrRecipeId); - } else { - getRecipeParents(math, ingrRecipeId, parents, visited); + if (visited.add(ingrRecipeId)) { + if (math.outputRecipes.containsKey(ingrRecipeId)) { + parents.add(ingrRecipeId); + } else { + getRecipeParents(math, ingrRecipeId, parents, visited); + } } }