Search in sources :

Example 1 with IRecipesGui

use of mezz.jei.api.runtime.IRecipesGui in project Botania by VazkiiMods.

the class JEIBotaniaPlugin method onRuntimeAvailable.

@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
    IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager();
    // Hide the return recipes (iron ingot/diamond/ender pearl returns, not lexicon)
    for (IElvenTradeRecipe recipe : TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().level)) {
        if (recipe instanceof LexiconElvenTradeRecipe) {
            continue;
        }
        List<Ingredient> inputs = recipe.getIngredients();
        List<ItemStack> outputs = recipe.getOutputs();
        if (inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(outputs.get(0))) {
            recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID);
        }
    }
    RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
    recipeManager.byKey(prefix("petal_apothecary/daybloom_motif")).ifPresent(r -> recipeRegistry.hideRecipe(r, PetalApothecaryRecipeCategory.UID));
    recipeManager.byKey(prefix("petal_apothecary/nightshade_motif")).ifPresent(r -> recipeRegistry.hideRecipe(r, PetalApothecaryRecipeCategory.UID));
    CorporeaInputHandler.jeiPanelSupplier = () -> {
        ItemStack stack = jeiRuntime.getIngredientListOverlay().getIngredientUnderMouse(VanillaTypes.ITEM);
        if (stack == null && Minecraft.getInstance().screen == jeiRuntime.getRecipesGui()) {
            stack = jeiRuntime.getRecipesGui().getIngredientUnderMouse(VanillaTypes.ITEM);
        }
        if (stack == null) {
            stack = jeiRuntime.getBookmarkOverlay().getIngredientUnderMouse(VanillaTypes.ITEM);
        }
        if (stack != null) {
            return stack;
        }
        return ItemStack.EMPTY;
    };
    CorporeaInputHandler.supportedGuiFilter = gui -> gui instanceof AbstractContainerScreen<?> || gui instanceof IRecipesGui;
}
Also used : IRecipeManager(mezz.jei.api.recipe.IRecipeManager) IElvenTradeRecipe(vazkii.botania.api.recipe.IElvenTradeRecipe) StateIngredient(vazkii.botania.api.recipe.StateIngredient) Ingredient(net.minecraft.world.item.crafting.Ingredient) AbstractContainerScreen(net.minecraft.client.gui.screens.inventory.AbstractContainerScreen) RecipeManager(net.minecraft.world.item.crafting.RecipeManager) IRecipeManager(mezz.jei.api.recipe.IRecipeManager) LexiconElvenTradeRecipe(vazkii.botania.common.crafting.LexiconElvenTradeRecipe) ItemStack(net.minecraft.world.item.ItemStack) IRecipesGui(mezz.jei.api.runtime.IRecipesGui)

Example 2 with IRecipesGui

use of mezz.jei.api.runtime.IRecipesGui in project RoughlyEnoughItems by shedaniel.

the class IGuiClickableArea method createBasic.

/**
 * Helper function to create the most basic type of {@link IGuiClickableArea},
 * which displays a recipe category on click.
 *
 * @since 9.5.0
 */
static IGuiClickableArea createBasic(int xPos, int yPos, int width, int height, RecipeType<?>... recipeTypes) {
    Rect2i area = new Rect2i(xPos, yPos, width, height);
    List<RecipeType<?>> recipeTypesList = Arrays.asList(recipeTypes);
    return new IGuiClickableArea() {

        @Override
        public Rect2i getArea() {
            return area;
        }

        @Override
        public void onClick(IFocusFactory focusFactory, IRecipesGui recipesGui) {
            recipesGui.showTypes(recipeTypesList);
        }
    };
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) RecipeType(mezz.jei.api.recipe.RecipeType) IFocusFactory(mezz.jei.api.recipe.IFocusFactory) IRecipesGui(mezz.jei.api.runtime.IRecipesGui)

Example 3 with IRecipesGui

use of mezz.jei.api.runtime.IRecipesGui in project PackagedAuto by TheLMiffy1111.

the class EncoderGuiHandler method getGuiClickableAreas.

@Override
public Collection<IGuiClickableArea> getGuiClickableAreas(EncoderScreen containerScreen, double mouseX, double mouseY) {
    Rect2i area = new Rect2i(172, 129, 22, 16);
    IGuiClickableArea clickableArea = new IGuiClickableArea() {

        @Override
        public Rect2i getArea() {
            return area;
        }

        @Override
        public void onClick(IFocusFactory focusFactory, IRecipesGui recipesGui) {
            List<ResourceLocation> categories = containerScreen.menu.patternItemHandler.recipeType.getJEICategories();
            if (categories.isEmpty()) {
                categories = PackagedAutoJEIPlugin.getAllRecipeCategories();
            }
            List<ResourceLocation> categories2 = categories;
            List<RecipeType<?>> types = PackagedAutoJEIPlugin.jeiRuntime.getRecipeManager().createRecipeCategoryLookup().get().<RecipeType<?>>map(c -> c.getRecipeType()).filter(t -> categories2.contains(t.getUid())).toList();
            if (!types.isEmpty()) {
                recipesGui.showTypes(types);
            }
        }
    };
    return Collections.singleton(clickableArea);
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) IGuiClickableArea(mezz.jei.api.gui.handlers.IGuiClickableArea) ResourceLocation(net.minecraft.resources.ResourceLocation) IGuiClickableArea(mezz.jei.api.gui.handlers.IGuiClickableArea) List(java.util.List) IFocusFactory(mezz.jei.api.recipe.IFocusFactory) Rect2i(net.minecraft.client.renderer.Rect2i) Collection(java.util.Collection) IGuiContainerHandler(mezz.jei.api.gui.handlers.IGuiContainerHandler) Collections(java.util.Collections) IRecipesGui(mezz.jei.api.runtime.IRecipesGui) RecipeType(mezz.jei.api.recipe.RecipeType) EncoderScreen(thelm.packagedauto.client.screen.EncoderScreen) RecipeType(mezz.jei.api.recipe.RecipeType) ResourceLocation(net.minecraft.resources.ResourceLocation) IFocusFactory(mezz.jei.api.recipe.IFocusFactory) IRecipesGui(mezz.jei.api.runtime.IRecipesGui)

Example 4 with IRecipesGui

use of mezz.jei.api.runtime.IRecipesGui in project RoughlyEnoughItems by shedaniel.

the class IGuiClickableArea method createBasic.

/**
 * Helper function to create the most basic type of {@link IGuiClickableArea},
 * which displays a recipe category on click.
 *
 * @deprecated use {@link #createBasic(int, int, int, int, RecipeType[])} instead.
 */
@Deprecated(forRemoval = true, since = "9.5.0")
static IGuiClickableArea createBasic(int xPos, int yPos, int width, int height, ResourceLocation... recipeCategoryUids) {
    Rect2i area = new Rect2i(xPos, yPos, width, height);
    List<ResourceLocation> recipeCategoryUidList = new ArrayList<>();
    Collections.addAll(recipeCategoryUidList, recipeCategoryUids);
    return new IGuiClickableArea() {

        @Override
        public Rect2i getArea() {
            return area;
        }

        @Override
        public void onClick(IFocusFactory focusFactory, IRecipesGui recipesGui) {
            recipesGui.showCategories(recipeCategoryUidList);
        }
    };
}
Also used : Rect2i(net.minecraft.client.renderer.Rect2i) ResourceLocation(net.minecraft.resources.ResourceLocation) ArrayList(java.util.ArrayList) IFocusFactory(mezz.jei.api.recipe.IFocusFactory) IRecipesGui(mezz.jei.api.runtime.IRecipesGui)

Aggregations

IRecipesGui (mezz.jei.api.runtime.IRecipesGui)4 IFocusFactory (mezz.jei.api.recipe.IFocusFactory)3 Rect2i (net.minecraft.client.renderer.Rect2i)3 RecipeType (mezz.jei.api.recipe.RecipeType)2 ResourceLocation (net.minecraft.resources.ResourceLocation)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 IGuiClickableArea (mezz.jei.api.gui.handlers.IGuiClickableArea)1 IGuiContainerHandler (mezz.jei.api.gui.handlers.IGuiContainerHandler)1 IRecipeManager (mezz.jei.api.recipe.IRecipeManager)1 AbstractContainerScreen (net.minecraft.client.gui.screens.inventory.AbstractContainerScreen)1 ItemStack (net.minecraft.world.item.ItemStack)1 Ingredient (net.minecraft.world.item.crafting.Ingredient)1 RecipeManager (net.minecraft.world.item.crafting.RecipeManager)1 EncoderScreen (thelm.packagedauto.client.screen.EncoderScreen)1 IElvenTradeRecipe (vazkii.botania.api.recipe.IElvenTradeRecipe)1 StateIngredient (vazkii.botania.api.recipe.StateIngredient)1 LexiconElvenTradeRecipe (vazkii.botania.common.crafting.LexiconElvenTradeRecipe)1