From 96f3f498fb5fc9e4327b4a328e5ae25b829c124d Mon Sep 17 00:00:00 2001 From: koolkrafter5 Date: Thu, 28 May 2026 12:36:58 -0400 Subject: [PATCH] Clean brewery handler --- .../client/integration/nei/IMCForNEI.java | 8 +++--- .../nei/recipe/RecipeHandlerBrewery.java | 25 ++++++++----------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java b/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java index ebdae9c33..8f3a60b83 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java +++ b/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java @@ -2,12 +2,14 @@ package vazkii.botania.client.integration.nei; import cpw.mods.fml.common.event.FMLInterModComms; import net.minecraft.nbt.NBTTagCompound; +import vazkii.botania.client.integration.nei.recipe.RecipeHandlerBrewery; public class IMCForNEI { public static void IMCSender() { - sendCatalyst("botania.brewery", "Botania:vial", -1); - sendCatalyst("botania.brewery", "Botania:vial:1", -1); - sendCatalyst("botania.brewery", "Botania:incenseStick", -1); + sendCatalyst(RecipeHandlerBrewery.OVERLAY, "Botania:vial", -1); + sendCatalyst(RecipeHandlerBrewery.OVERLAY, "Botania:vial:1", -1); + sendCatalyst(RecipeHandlerBrewery.OVERLAY, "Botania:incenseStick", -1); + sendCatalyst(RecipeHandlerBrewery.OVERLAY, "Botania:bloodPendant", -1); } private static void sendCatalyst(String handlerName, String stack, int priority) { diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java index e94c32364..971b7d7d4 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerBrewery.java @@ -23,6 +23,8 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerBrewery extends TemplateRecipeHandler { + public static final String OVERLAY = "botania.brewery"; + public class CachedBreweryRecipe extends CachedRecipe { public List inputs = new ArrayList<>(); @@ -38,8 +40,8 @@ public class RecipeHandlerBrewery extends TemplateRecipeHandler { toVial = new ItemStack(ModItems.vial); } else { toVial = vial.copy(); + toVial.stackSize = 1; } - toVial.stackSize = 1; inputs.add(new PositionedStack(toVial, 39, 42)); output = new PositionedStack(recipe.getOutput(toVial), 87, 42); @@ -52,14 +54,13 @@ public class RecipeHandlerBrewery extends TemplateRecipeHandler { public void setIngredients(List inputs) { int left = 96 - inputs.size() * 18 / 2; - int i = 0; - for (Object o : inputs) { - if (o instanceof String) { - this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6)); + for (int i = 0; i < inputs.size(); i++) { + Object o = inputs.get(i); + if (o instanceof String oredict) { + this.inputs.add(new PositionedStack(OreDictionary.getOres(oredict), left + i * 18, 6)); } else { this.inputs.add(new PositionedStack(o, left + i * 18, 6)); } - i++; } } @@ -82,7 +83,7 @@ public class RecipeHandlerBrewery extends TemplateRecipeHandler { @Override public String getOverlayIdentifier() { - return "botania.brewery"; + return OVERLAY; } @Override @@ -115,11 +116,9 @@ public class RecipeHandlerBrewery extends TemplateRecipeHandler { @Override public void loadCraftingRecipes(ItemStack result) { - if (!(result.getItem() instanceof IBrewItem)) { - return; - } + if (!(result.getItem() instanceof IBrewItem brew)) return; for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if (recipe != null && ((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) { + if (recipe != null && brew.getBrew(result) == recipe.getBrew()) { arecipes.add(new CachedBreweryRecipe(recipe)); } } @@ -135,9 +134,7 @@ public class RecipeHandlerBrewery extends TemplateRecipeHandler { } } else { for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if (recipe == null) - continue; - + if (recipe == null) continue; CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) { arecipes.add(crecipe);