From 9fca30df29426bad97a6da18dbbbb0a26f9a403e Mon Sep 17 00:00:00 2001 From: koolkrafter5 Date: Fri, 20 Mar 2026 19:52:20 -0400 Subject: [PATCH] Clean up mana pool handler and make the transfer rect actually work by just rendering the mana pool item rather than adding it as an itemstack # Conflicts: # src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java --- .../nei/recipe/RecipeHandlerManaPool.java | 204 ++++++++++-------- 1 file changed, 110 insertions(+), 94 deletions(-) diff --git a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java index dc721695e..05aea0bc2 100644 --- a/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java +++ b/src/main/java/vazkii/botania/client/integration/nei/recipe/RecipeHandlerManaPool.java @@ -1,13 +1,12 @@ package vazkii.botania.client.integration.nei.recipe; import java.awt.Rectangle; -import java.util.ArrayList; -import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.item.Item; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraftforge.oredict.OreDictionary; @@ -28,115 +27,132 @@ import vazkii.botania.common.core.helper.ItemNBTHelper; public class RecipeHandlerManaPool extends TemplateRecipeHandler { - public class CachedManaPoolRecipe extends CachedRecipe { + private static final RenderItem renderItem = new RenderItem(); + private static final Minecraft mc = Minecraft.getMinecraft(); + private static final ItemStack poolStack = new ItemStack(ModBlocks.pool); - public List inputs = new ArrayList<>(); - public PositionedStack output; - public List otherStacks = new ArrayList<>(); - public int mana; + public class CachedManaPoolRecipe extends CachedRecipe { - public CachedManaPoolRecipe(RecipeManaInfusion recipe) { - if(recipe == null) - return; - inputs.add(new PositionedStack(new ItemStack(ModBlocks.pool, 1, recipe.getOutput().getItem() == Item.getItemFromBlock(ModBlocks.pool) ? 2 : 0), 71, 37)); + public PositionedStack input; + public PositionedStack output; + public PositionedStack catalyst; + public int mana; - if(recipe.getInput() instanceof String) - inputs.add(new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37)); - else inputs.add(new PositionedStack(recipe.getInput(), 42, 37)); + public CachedManaPoolRecipe(RecipeManaInfusion recipe) { + if (recipe == null) return; - if(recipe.isAlchemy()) - otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37)); - else if (recipe.isConjuration()) - otherStacks.add(new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37)); + if (recipe.getInput() instanceof String) { + input = new PositionedStack(OreDictionary.getOres((String) recipe.getInput()), 42, 37); + } else { + input = new PositionedStack(recipe.getInput(), 42, 37); + } - output = new PositionedStack(recipe.getOutput(), 101, 37); - // This value is where the mana bar is stored initially - mana = recipe.getManaToConsume(); - } + if (recipe.isAlchemy()) { + catalyst = new PositionedStack(new ItemStack(ModBlocks.alchemyCatalyst), 10, 37); + } else if (recipe.isConjuration()) { + catalyst = new PositionedStack(new ItemStack(ModBlocks.conjurationCatalyst), 10, 37); + } - @Override - public List getIngredients() { - return inputs; - } + output = new PositionedStack(recipe.getOutput(), 101, 37); + mana = recipe.getManaToConsume(); + } - @Override - public PositionedStack getResult() { - return output; - } + @Override + public PositionedStack getIngredient() { + return input; + } - @Override - public List getOtherStacks() { - return otherStacks; - } + @Override + public PositionedStack getResult() { + return output; + } - } + @Override + public PositionedStack getOtherStack() { + return catalyst; + } - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.manaPool"); - } + } - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BLANK; - } + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.manaPool"); + } - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), "botania.manaPool")); - } + @Override + public String getOverlayIdentifier() { + return "botania.manaPool"; + } - @Override - public void drawBackground(int recipe) { - super.drawBackground(recipe); - GL11.glEnable(GL11.GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); - // Mana infusion is the mana pool, super weird. - GuiDraw.changeTexture(LibResources.GUI_MANA_INFUSION_OVERLAY); - GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50); - // Below is where the mana bar actually drawn. - int tempMana = ((CachedManaPoolRecipe) arecipes.get(recipe)).mana; - HUDHandler.renderManaBar(32, 80, 0x0000FF, 0.75F, GuiScreen.isShiftKeyDown() ? tempMana : tempMana * 10, TilePool.MAX_MANA / 10); - FontRenderer font = Minecraft.getMinecraft().fontRenderer; - String size = GuiScreen.isShiftKeyDown() ? "1x" : "10x"; - String localized = StatCollector.translateToLocalFormatted("botaniamisc.neiratio", size); - font.drawString(localized, 84 - font.getStringWidth(localized) / 2, 71, 0x000000); - RenderTilePool.forceMana = true; - } + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BLANK; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.manaPool")) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe == null) - continue; + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(70, 36, 18, 18), getOverlayIdentifier())); + } - arecipes.add(new CachedManaPoolRecipe(recipe)); - } - } else super.loadCraftingRecipes(outputId, results); - } + @Override + public void drawBackground(int recipe) { + super.drawBackground(recipe); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + // Arrows + GuiDraw.changeTexture(LibResources.GUI_MANA_INFUSION_OVERLAY); + GuiDraw.drawTexturedModalRect(45, 20, 38, 35, 92, 50); + // Mana bar + int tempMana = ((CachedManaPoolRecipe) arecipes.get(recipe)).mana; + HUDHandler.renderManaBar(32, 80, 0x0000FF, 0.75F, GuiScreen.isShiftKeyDown() ? tempMana : tempMana * 10, TilePool.MAX_MANA / 10); + FontRenderer font = Minecraft.getMinecraft().fontRenderer; + String size = GuiScreen.isShiftKeyDown() ? "1x" : "10x"; + String localized = StatCollector.translateToLocalFormatted("botaniamisc.neiratio", size); + font.drawString(localized, 84 - font.getStringWidth(localized) / 2, 71, 0x000000); + GL11.glDisable(GL11.GL_BLEND); + // Mana pool item + RenderHelper.enableGUIStandardItemLighting(); + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderTilePool.forceMana = true; + renderItem.renderItemIntoGUI(font, mc.getTextureManager(), poolStack, 71, 37); + GL11.glDisable(GL11.GL_DEPTH_TEST); + RenderHelper.disableStandardItemLighting(); + } - @Override - public void loadCraftingRecipes(ItemStack result) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe == null) - continue; + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe == null) continue; - if(ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) - arecipes.add(new CachedManaPoolRecipe(recipe)); - } - } + arecipes.add(new CachedManaPoolRecipe(recipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) { - for(RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { - if(recipe == null) - continue; + @Override + public void loadCraftingRecipes(ItemStack result) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe == null) continue; - CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) - arecipes.add(crecipe); - } - } + if (ItemNBTHelper.areStacksSameTypeCraftingWithNBT(recipe.getOutput(), result)) { + arecipes.add(new CachedManaPoolRecipe(recipe)); + } + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (RecipeManaInfusion recipe : BotaniaAPI.manaInfusionRecipes) { + if (recipe == null) continue; + + CachedManaPoolRecipe crecipe = new CachedManaPoolRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getIngredients(), ingredient) || ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.getOtherStacks(), ingredient)) { + arecipes.add(crecipe); + } + } + } }