From 03cbcecd528a1dff675fa0312f85567fd81aec5b Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 3 Sep 2024 19:15:09 -0400 Subject: [PATCH] Avoid creating duplicate ResourceLocation objects for anvil enchantment recipes --- .../library/plugins/vanilla/anvil/AnvilRecipeMaker.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/src/main/java/mezz/jei/library/plugins/vanilla/anvil/AnvilRecipeMaker.java b/Library/src/main/java/mezz/jei/library/plugins/vanilla/anvil/AnvilRecipeMaker.java index 16e007bf5..519fd53e5 100644 --- a/Library/src/main/java/mezz/jei/library/plugins/vanilla/anvil/AnvilRecipeMaker.java +++ b/Library/src/main/java/mezz/jei/library/plugins/vanilla/anvil/AnvilRecipeMaker.java @@ -115,16 +115,16 @@ private static Stream getBookEnchantmentRecipes( ItemStack ingredient ) { var ingredientSingletonList = List.of(ingredient); + String ingredientId = EnchantedBookSubtypeInterpreter.INSTANCE.getStringName(ingredient); + String ingredientIdPath = ResourceLocationUtil.sanitizePath(ingredientId); + String id = "enchantment." + ingredientIdPath; + ResourceLocation uid = ResourceLocation.fromNamespaceAndPath(ModIds.MINECRAFT_ID, id); return enchantmentDatas.stream() .filter(data -> data.canEnchant(ingredient)) .map(data -> data.getEnchantedBooks(ingredient)) .filter(enchantedBooks -> !enchantedBooks.isEmpty()) .map(enchantedBooks -> { List outputs = getEnchantedIngredients(ingredient, enchantedBooks); - String ingredientId = EnchantedBookSubtypeInterpreter.INSTANCE.getStringName(ingredient); - String ingredientIdPath = ResourceLocationUtil.sanitizePath(ingredientId); - String id = "enchantment." + ingredientIdPath; - ResourceLocation uid = ResourceLocation.fromNamespaceAndPath(ModIds.MINECRAFT_ID, id); // All lists given here are immutable, and we want to keep the transforming list from outputs, // so we call the AnvilRecipe constructor directly return new AnvilRecipe(ingredientSingletonList, enchantedBooks, outputs, uid);