diff --git a/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java b/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java new file mode 100644 index 000000000..f6699d7c6 --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/nei/IMCForNEI.java @@ -0,0 +1,22 @@ +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() { + String brewery = new RecipeHandlerBrewery().getOverlayIdentifier(); + sendCatalyst(brewery, "Botania:vial", -1); + sendCatalyst(brewery, "Botania:vial:1", -1); + sendCatalyst(brewery, "Botania:incenseStick", -1); + } + + private static void sendCatalyst(String handlerName, String stack, int priority) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString("handlerID", handlerName); + nbt.setString("itemName", stack); + nbt.setInteger("priority", priority); + FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", nbt); + } +} 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 15680bb19..e94c32364 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,118 +23,127 @@ import codechicken.nei.recipe.TemplateRecipeHandler; public class RecipeHandlerBrewery extends TemplateRecipeHandler { - public class CachedBreweryRecipe extends CachedRecipe { + public class CachedBreweryRecipe extends CachedRecipe { - public List inputs = new ArrayList<>(); - public PositionedStack output; - public int mana; + public List inputs = new ArrayList<>(); + public PositionedStack output; + public int mana; - public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) { - if(recipe == null) - return; + public CachedBreweryRecipe(RecipeBrew recipe, ItemStack vial) { + if (recipe == null) return; - setIngredients(recipe.getInputs()); - ItemStack toVial; - if (vial == null) - toVial = new ItemStack(ModItems.vial); - else - toVial = vial.copy(); - toVial.stackSize = 1; - inputs.add(new PositionedStack(toVial, 39, 42)); + setIngredients(recipe.getInputs()); + ItemStack toVial; + if (vial == null) { + toVial = new ItemStack(ModItems.vial); + } else { + toVial = vial.copy(); + } + toVial.stackSize = 1; + inputs.add(new PositionedStack(toVial, 39, 42)); - output = new PositionedStack(recipe.getOutput(toVial), 87, 42); - } + output = new PositionedStack(recipe.getOutput(toVial), 87, 42); + } - public CachedBreweryRecipe(RecipeBrew recipe) { - this(recipe, null); - } + public CachedBreweryRecipe(RecipeBrew recipe) { + this(recipe, null); + } - public void setIngredients(List inputs) { - int left = 96 - inputs.size() * 18 / 2; + 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)); - else - this.inputs.add(new PositionedStack(o, left + i * 18, 6)); + int i = 0; + for (Object o : inputs) { + if (o instanceof String) { + this.inputs.add(new PositionedStack(OreDictionary.getOres((String) o), left + i * 18, 6)); + } else { + this.inputs.add(new PositionedStack(o, left + i * 18, 6)); + } + i++; + } + } - i++; - } - } + @Override + public List getIngredients() { + return inputs; + } - @Override - public List getIngredients() { - return inputs; - } + @Override + public PositionedStack getResult() { + return output; + } - @Override - public PositionedStack getResult() { - return output; - } + } - } + @Override + public String getRecipeName() { + return StatCollector.translateToLocal("botania.nei.brewery"); + } - @Override - public String getRecipeName() { - return StatCollector.translateToLocal("botania.nei.brewery"); - } + @Override + public String getOverlayIdentifier() { + return "botania.brewery"; + } - @Override - public String getGuiTexture() { - return LibResources.GUI_NEI_BREWERY; - } + @Override + public String getGuiTexture() { + return LibResources.GUI_NEI_BREWERY; + } - @Override - public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), "botania.brewery")); - } + @Override + public void loadTransferRects() { + transferRects.add(new RecipeTransferRect(new Rectangle(87, 25, 15, 14), getOverlayIdentifier())); + } - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); - } + @Override + public void drawBackground(int recipe) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GuiDraw.changeTexture(getGuiTexture()); + GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 166, 65); + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if(outputId.equals("botania.brewery")) - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) - arecipes.add(new CachedBreweryRecipe(recipe)); - else super.loadCraftingRecipes(outputId, results); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getOverlayIdentifier())) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + arecipes.add(new CachedBreweryRecipe(recipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) { - if(result.getItem() instanceof IBrewItem) - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if(recipe == null) - continue; + @Override + public void loadCraftingRecipes(ItemStack result) { + if (!(result.getItem() instanceof IBrewItem)) { + return; + } + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if (recipe != null && ((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) { + arecipes.add(new CachedBreweryRecipe(recipe)); + } + } + } - if(((IBrewItem) result.getItem()).getBrew(result) == recipe.getBrew()) - arecipes.add(new CachedBreweryRecipe(recipe)); - } - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + if (ingredient.getItem() instanceof IBrewContainer) { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if (recipe != null && recipe.getOutput(ingredient) != null) { + arecipes.add(new CachedBreweryRecipe(recipe, ingredient)); + } + } + } else { + for (RecipeBrew recipe : BotaniaAPI.brewRecipes) { + if (recipe == null) + continue; - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if(ingredient.getItem() instanceof IBrewContainer) { - for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if(recipe == null) - continue; - - if(recipe.getOutput(ingredient) != null) - arecipes.add(new CachedBreweryRecipe(recipe, ingredient)); - } - } else for(RecipeBrew recipe : BotaniaAPI.brewRecipes) { - if(recipe == null) - continue; - - CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); - if(ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) - arecipes.add(crecipe); - } - } + CachedBreweryRecipe crecipe = new CachedBreweryRecipe(recipe); + if (ItemNBTHelper.cachedRecipeContainsWithNBT(crecipe.inputs, ingredient)) { + arecipes.add(crecipe); + } + } + } + } } diff --git a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java index 24c14e5f4..19f743fee 100644 --- a/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java +++ b/src/main/java/vazkii/botania/common/core/proxy/CommonProxy.java @@ -33,6 +33,7 @@ import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ITwoNamedPage; import vazkii.botania.api.lexicon.LexiconEntry; import vazkii.botania.api.lexicon.LexiconPage; +import vazkii.botania.client.integration.nei.IMCForNEI; import vazkii.botania.common.Botania; import vazkii.botania.common.achievement.ModAchievements; import vazkii.botania.common.block.ModBlocks; @@ -84,6 +85,7 @@ import vazkii.botania.common.world.SkyblockWorldEvents; import vazkii.botania.common.world.WorldTypeSkyblock; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; @@ -152,6 +154,10 @@ public class CommonProxy { new StatementAPIPlugin(); LexiconData.init(); + + if (Loader.isModLoaded("NotEnoughItems")) { + IMCForNEI.IMCSender(); + } } public void postInit(FMLPostInitializationEvent event) {