From eb473f4b47bb86221298dd2a0682b2733d647654 Mon Sep 17 00:00:00 2001 From: mezz Date: Sat, 6 Apr 2019 17:53:32 -0700 Subject: [PATCH] Fix #1518 Add support for Crafttweaker removing brewing recipes --- .../vanilla/brewing/BrewingRecipeMaker.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/mezz/jei/plugins/vanilla/brewing/BrewingRecipeMaker.java b/src/main/java/mezz/jei/plugins/vanilla/brewing/BrewingRecipeMaker.java index c8377ccfe..271f2874b 100644 --- a/src/main/java/mezz/jei/plugins/vanilla/brewing/BrewingRecipeMaker.java +++ b/src/main/java/mezz/jei/plugins/vanilla/brewing/BrewingRecipeMaker.java @@ -16,7 +16,6 @@ import net.minecraftforge.common.brewing.VanillaBrewingRecipe; import net.minecraft.init.PotionTypes; import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionHelper; import net.minecraft.potion.PotionType; import net.minecraft.potion.PotionUtils; import net.minecraft.util.NonNullList; @@ -47,8 +46,13 @@ private List getBrewingRecipes() { Set recipes = new HashSet<>(); - addVanillaBrewingRecipes(recipes); - addModdedBrewingRecipes(recipes); + Collection brewingRecipes = BrewingRecipeRegistry.getRecipes(); + brewingRecipes.stream() + .filter(r -> r instanceof VanillaBrewingRecipe) + .map(r -> (VanillaBrewingRecipe) r) + .findFirst() + .ifPresent(vanillaBrewingRecipe -> addVanillaBrewingRecipes(recipes, vanillaBrewingRecipe)); + addModdedBrewingRecipes(brewingRecipes, recipes); List recipeList = new ArrayList<>(recipes); recipeList.sort(Comparator.comparingInt(BrewingRecipeWrapper::getBrewingSteps)); @@ -56,7 +60,7 @@ private List getBrewingRecipes() { return recipeList; } - private void addVanillaBrewingRecipes(Collection recipes) { + private void addVanillaBrewingRecipes(Collection recipes, VanillaBrewingRecipe vanillaBrewingRecipe) { List potionIngredients = ingredientRegistry.getPotionIngredients(); List knownPotions = new ArrayList<>(); @@ -64,18 +68,18 @@ private void addVanillaBrewingRecipes(Collection recipes) boolean foundNewPotions; do { - List newPotions = getNewPotions(knownPotions, potionIngredients, recipes); + List newPotions = getNewPotions(knownPotions, potionIngredients, recipes, vanillaBrewingRecipe); foundNewPotions = !newPotions.isEmpty(); knownPotions.addAll(newPotions); } while (foundNewPotions); } - private List getNewPotions(List knownPotions, List potionIngredients, Collection recipes) { + private List getNewPotions(List knownPotions, List potionIngredients, Collection recipes, VanillaBrewingRecipe vanillaBrewingRecipe) { List newPotions = new ArrayList<>(); for (ItemStack potionInput : knownPotions) { for (ItemStack potionIngredient : potionIngredients) { - ItemStack potionOutput = PotionHelper.doReaction(potionIngredient, potionInput.copy()); - if (potionOutput.equals(potionInput)) { + ItemStack potionOutput = vanillaBrewingRecipe.getOutput(potionInput.copy(), potionIngredient); + if (potionOutput.isEmpty()) { continue; } @@ -107,11 +111,6 @@ private List getNewPotions(List knownPotions, List recipes) { - Collection brewingRecipes = BrewingRecipeRegistry.getRecipes(); - addModdedBrewingRecipes(brewingRecipes, recipes); - } - private void addModdedBrewingRecipes(Collection brewingRecipes, Collection recipes) { for (IBrewingRecipe iBrewingRecipe : brewingRecipes) { if (iBrewingRecipe instanceof AbstractBrewingRecipe) {