Search in sources :

Example 1 with IRecipeWrapper

use of mezz.jei.api.recipe.IRecipeWrapper 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 IRecipeWrapper

use of mezz.jei.api.recipe.IRecipeWrapper in project artisan-worktables by codetaylor.

the class PluginGameStages method processStagedRecipes.

@SideOnly(Side.CLIENT)
private void processStagedRecipes() {
    if (!FMLCommonHandler.instance().getEffectiveSide().isClient()) {
        return;
    }
    if (PluginJEI.RECIPE_REGISTRY == null) {
        return;
    }
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    Collection<String> unlockedStages = GameStagesHelper.getUnlockedStages(player);
    GameStagesRequirementContext context = (GameStagesRequirementContext) ArtisanAPI.getRequirementContext(new ResourceLocation(ModArtisanWorktables.MOD_ID, "gamestages"));
    context.setUnlockedStages(unlockedStages);
    for (String name : ArtisanAPI.getWorktableNames()) {
        RecipeRegistry registry = ArtisanAPI.getWorktableRecipeRegistry(name);
        if (registry != null) {
            for (EnumTier tier : EnumTier.values()) {
                List<IArtisanRecipe> recipeList = registry.getRecipeListByTier(new ArrayList<>(), tier);
                String uid = PluginJEI.createUID(name, tier);
                for (IArtisanRecipe recipe : recipeList) {
                    IRecipeWrapper recipeWrapper = PluginJEI.RECIPE_REGISTRY.getRecipeWrapper(recipe, uid);
                    if (recipeWrapper == null) {
                        continue;
                    }
                    IRequirement requirement = recipe.getRequirement(GameStagesRequirement.LOCATION);
                    // noinspection unchecked
                    if (requirement == null || requirement.match(context)) {
                        PluginJEI.RECIPE_REGISTRY.unhideRecipe(recipeWrapper);
                    } else {
                        PluginJEI.RECIPE_REGISTRY.hideRecipe(recipeWrapper);
                    }
                }
            }
        }
    }
}
Also used : IRequirement(com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirement) GameStagesRequirementContext(com.codetaylor.mc.artisanworktables.modules.requirement.gamestages.requirement.GameStagesRequirementContext) ResourceLocation(net.minecraft.util.ResourceLocation) IArtisanRecipe(com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) EnumTier(com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier) RecipeRegistry(com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeRegistry) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with IRecipeWrapper

use of mezz.jei.api.recipe.IRecipeWrapper in project Adventurers-Toolbox by the-realest-stu.

the class ToolboxJEIPlugin method register.

@Override
public void register(IModRegistry reg) {
    IJeiHelpers helper = reg.getJeiHelpers();
    IGuiHelper guiHelper = helper.getGuiHelper();
    reg.handleRecipes(BookRecipe.class, new IRecipeWrapperFactory<BookRecipe>() {

        @Override
        public IRecipeWrapper getRecipeWrapper(BookRecipe recipe) {
            return new GuideBookRecipeWrapper();
        }
    }, VanillaRecipeCategoryUid.CRAFTING);
}
Also used : IGuiHelper(mezz.jei.api.IGuiHelper) BookRecipe(toolbox.common.recipes.BookRecipe) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) IJeiHelpers(mezz.jei.api.IJeiHelpers)

Example 4 with IRecipeWrapper

use of mezz.jei.api.recipe.IRecipeWrapper in project EnderIO by SleepyTrousers.

the class DarkSteelUpgradeRecipeCategory method registerBookEnchantmentRecipes.

private static int registerBookEnchantmentRecipes(@Nonnull IModRegistry registry, @Nonnull NNList<ItemStack> ingredients) {
    int count = 0;
    Collection<Enchantment> enchantments = ForgeRegistries.ENCHANTMENTS.getValuesCollection();
    List<IRecipeWrapper> anvilRecipes = new ArrayList<>();
    IVanillaRecipeFactory factory = registry.getJeiHelpers().getVanillaRecipeFactory();
    for (ItemStack ingredient : ingredients) {
        if (ingredient.isItemEnchantable()) {
            for (Enchantment enchantment : enchantments) {
                if (enchantment.canApply(ingredient)) {
                    Item item = ingredient.getItem();
                    List<ItemStack> perLevelBooks = Lists.newArrayList();
                    List<ItemStack> perLevelOutputs = Lists.newArrayList();
                    for (int level = 1; level <= enchantment.getMaxLevel(); level++) {
                        Map<Enchantment, Integer> enchMap = Collections.singletonMap(enchantment, level);
                        ItemStack bookEnchant = new ItemStack(Items.ENCHANTED_BOOK);
                        EnchantmentHelper.setEnchantments(enchMap, bookEnchant);
                        if (item.isBookEnchantable(ingredient, bookEnchant)) {
                            perLevelBooks.add(bookEnchant);
                            ItemStack withEnchant = ingredient.copy();
                            EnchantmentHelper.setEnchantments(enchMap, withEnchant);
                            perLevelOutputs.add(withEnchant);
                        }
                    }
                    if (!perLevelBooks.isEmpty() && !perLevelOutputs.isEmpty()) {
                        anvilRecipes.add(factory.createAnvilRecipe(ingredient, perLevelBooks, perLevelOutputs));
                        count++;
                    }
                }
            }
        }
    }
    registry.addRecipes(anvilRecipes, VanillaRecipeCategoryUid.ANVIL);
    return count;
}
Also used : Item(net.minecraft.item.Item) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) ArrayList(java.util.ArrayList) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) Enchantment(net.minecraft.enchantment.Enchantment) ItemStack(net.minecraft.item.ItemStack) IVanillaRecipeFactory(mezz.jei.api.recipe.IVanillaRecipeFactory)

Example 5 with IRecipeWrapper

use of mezz.jei.api.recipe.IRecipeWrapper in project EnderIO by SleepyTrousers.

the class DarkSteelUpgradeRecipeCategory method register.

public static void register(IModRegistry registry) {
    long start = System.nanoTime();
    registry.addRecipeCatalyst(new ItemStack(blockDarkSteelAnvil.getBlockNN()), VanillaRecipeCategoryUid.ANVIL);
    NNList<ItemStack> blacklist = new NNList<>();
    for (UpgradePath rec : allRecipes) {
        rec.getOutput().getItem().getSubItems(getCreativeTab(rec), blacklist);
    }
    NNList<ItemStack> seen = new NNList<>();
    for (UpgradePath rec : allRecipes) {
        if (!inList(blacklist, rec.getOutput()) && !inList(seen, rec.getOutput())) {
            seen.add(rec.getOutput());
        }
    }
    int enchantmentRecipes = registerBookEnchantmentRecipes(registry, seen);
    final IVanillaRecipeFactory factory = registry.getJeiHelpers().getVanillaRecipeFactory();
    Collection<IRecipeWrapper> anvilRecipes = NullHelper.notnullJ(allRecipes.stream().map(rec -> factory.createAnvilRecipe(rec.getInput(), Collections.singletonList(rec.getUpgrade()), Collections.singletonList(rec.getOutput()))).collect(Collectors.toList()), "Stream#collect");
    registry.addRecipes(anvilRecipes, VanillaRecipeCategoryUid.ANVIL);
    Log.info(String.format("DarkSteelUpgradeRecipeCategory: Added %d dark steel upgrade recipes and %d enchantment recipes for upgradable items to JEI in %.3f seconds.", allRecipes.size(), enchantmentRecipes, (System.nanoTime() - start) / 1000000000d));
}
Also used : UpgradePath(crazypants.enderio.base.handler.darksteel.DarkSteelRecipeManager.UpgradePath) NNList(com.enderio.core.common.util.NNList) IRecipeWrapper(mezz.jei.api.recipe.IRecipeWrapper) ItemStack(net.minecraft.item.ItemStack) IVanillaRecipeFactory(mezz.jei.api.recipe.IVanillaRecipeFactory)

Aggregations

IRecipeWrapper (mezz.jei.api.recipe.IRecipeWrapper)7 ItemStack (net.minecraft.item.ItemStack)4 ArrayList (java.util.ArrayList)3 IGuiHelper (mezz.jei.api.IGuiHelper)2 IVanillaRecipeFactory (mezz.jei.api.recipe.IVanillaRecipeFactory)2 InfuserRecipeWrapper (betterwithaddons.interaction.jei.wrapper.InfuserRecipeWrapper)1 FenceDescription (binnie.extratrees.blocks.decor.FenceDescription)1 FenceType (binnie.extratrees.blocks.decor.FenceType)1 MultiFenceRecipePattern (binnie.extratrees.blocks.decor.MultiFenceRecipePattern)1 IPlankType (binnie.extratrees.wood.planks.IPlankType)1 RecipeRegistry (com.codetaylor.mc.artisanworktables.api.internal.recipe.RecipeRegistry)1 EnumTier (com.codetaylor.mc.artisanworktables.api.internal.reference.EnumTier)1 IArtisanRecipe (com.codetaylor.mc.artisanworktables.api.recipe.IArtisanRecipe)1 IRequirement (com.codetaylor.mc.artisanworktables.api.recipe.requirement.IRequirement)1 GameStagesRequirementContext (com.codetaylor.mc.artisanworktables.modules.requirement.gamestages.requirement.GameStagesRequirementContext)1 NNList (com.enderio.core.common.util.NNList)1 IDarkSteelItem (crazypants.enderio.api.upgrades.IDarkSteelItem)1 UpgradePath (crazypants.enderio.base.handler.darksteel.DarkSteelRecipeManager.UpgradePath)1 List (java.util.List)1 ImbuingRecipeWrapper (lumien.randomthings.handler.compability.jei.imbuing.ImbuingRecipeWrapper)1