Search in sources :

Example 1 with IShapedCraftingRecipeWrapper

use of mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper in project BetterWithAddons by DaedalusGame.

the class InfuserRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    guiItemStacks.init(craftOutputSlot, false, 107, 29);
    for (int y = 0; y < 3; ++y) {
        for (int x = 0; x < 3; ++x) {
            int index = craftInputSlot1 + x + (y * 3);
            guiItemStacks.init(index, true, 13 + x * 18, 11 + y * 18);
        }
    }
    if (recipeWrapper instanceof InfuserRecipeWrapper) {
        IRecipeWrapper innerWrapper = ((InfuserRecipeWrapper) recipeWrapper).getInner();
        if (innerWrapper instanceof ICustomCraftingRecipeWrapper) {
            ICustomCraftingRecipeWrapper customWrapper = (ICustomCraftingRecipeWrapper) innerWrapper;
            customWrapper.setRecipe(recipeLayout, ingredients);
            return;
        }
        List<List<ItemStack>> inputs = ingredients.getInputs(ItemStack.class);
        List<List<ItemStack>> outputs = ingredients.getOutputs(ItemStack.class);
        if (innerWrapper instanceof IShapedCraftingRecipeWrapper) {
            IShapedCraftingRecipeWrapper wrapper = (IShapedCraftingRecipeWrapper) innerWrapper;
            craftingGridHelper.setInputs(guiItemStacks, inputs, wrapper.getWidth(), wrapper.getHeight());
        } else {
            craftingGridHelper.setInputs(guiItemStacks, inputs);
            recipeLayout.setShapeless();
        }
        guiItemStacks.set(craftOutputSlot, outputs.get(0));
    }
}
Also used : IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) ICustomCraftingRecipeWrapper(mezz.jei.api.recipe.wrapper.ICustomCraftingRecipeWrapper) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) List(java.util.List) InfuserRecipeWrapper(betterwithaddons.interaction.jei.wrapper.InfuserRecipeWrapper) IShapedCraftingRecipeWrapper(mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper)

Example 2 with IShapedCraftingRecipeWrapper

use of mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper in project CraftTweaker by CraftTweaker.

the class ConflictCommand method gatherRecipes.

/**
 * Collects all recipes, converts them to the own class and adds them to the List
 */
private void gatherRecipes() {
    IRecipeRegistry reg = JEIAddonPlugin.recipeRegistry;
    for (IRecipeCategory category : reg.getRecipeCategories()) {
        if (category instanceof CraftingRecipeCategory) {
            List wrappers = reg.getRecipeWrappers(category);
            for (Object wrapper : wrappers) {
                if (wrapper instanceof IRecipeWrapper && !(wrapper instanceof TippedArrowRecipeWrapper)) {
                    IRecipeWrapper wrap = ((IRecipeWrapper) wrapper);
                    IIngredients ing = new Ingredients();
                    wrap.getIngredients(ing);
                    List<List<ItemStack>> inputs = ing.getInputs(ItemStack.class);
                    List<List<ItemStack>> outputs = ing.getOutputs(ItemStack.class);
                    // checks for having no outputs or having a "null" output
                    ItemStack output = outputs.size() > 0 ? outputs.get(0) != null ? outputs.get(0).size() > 0 ? outputs.get(0).get(0) : null : null : null;
                    // prevent checking recipes with "null" output
                    if (output == null) {
                        continue;
                    }
                    // differs shaped an shapeless recipes
                    if (wrapper instanceof IShapedCraftingRecipeWrapper) {
                        craftingRecipeEntries.add(new CraftingRecipeEntry(inputs, output, ((IShapedCraftingRecipeWrapper) wrapper).getWidth(), ((IShapedCraftingRecipeWrapper) wrapper).getHeight(), "noname"));
                    } else {
                        craftingRecipeEntries.add(new CraftingRecipeEntry(inputs, output, "noname"));
                    }
                }
            }
        }
    }
}
Also used : Ingredients(mezz.jei.ingredients.Ingredients) IIngredients(mezz.jei.api.ingredients.IIngredients) IRecipeRegistry(mezz.jei.api.IRecipeRegistry) IIngredients(mezz.jei.api.ingredients.IIngredients) ItemStack(net.minecraft.item.ItemStack) IShapedCraftingRecipeWrapper(mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper)

Aggregations

IShapedCraftingRecipeWrapper (mezz.jei.api.recipe.wrapper.IShapedCraftingRecipeWrapper)2 InfuserRecipeWrapper (betterwithaddons.interaction.jei.wrapper.InfuserRecipeWrapper)1 List (java.util.List)1 IRecipeRegistry (mezz.jei.api.IRecipeRegistry)1 IGuiItemStackGroup (mezz.jei.api.gui.IGuiItemStackGroup)1 IIngredients (mezz.jei.api.ingredients.IIngredients)1 IRecipeWrapper (mezz.jei.api.recipe.IRecipeWrapper)1 ICustomCraftingRecipeWrapper (mezz.jei.api.recipe.wrapper.ICustomCraftingRecipeWrapper)1 Ingredients (mezz.jei.ingredients.Ingredients)1 ItemStack (net.minecraft.item.ItemStack)1