Search in sources :

Example 1 with EnergyIngredient

use of crazypants.enderio.base.integration.jei.energy.EnergyIngredient in project EnderIO by SleepyTrousers.

the class PainterRecipeCategory method setRecipe.

@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull PainterRecipeCategory.PainterRecipeWrapper currentRecipe, @Nonnull IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);
    guiItemStacks.init(0, true, 67 - xOff - 1, 34 - yOff - 1);
    guiItemStacks.init(1, true, 38 - xOff - 1, 34 - yOff - 1);
    guiItemStacks.init(2, false, 121 - xOff - 1, 34 - yOff - 1);
    group.init(3, true, EnergyIngredientRenderer.INSTANCE, 108 - xOff, 60 - yOff, 50, 10, 0, 0);
    IFocus<?> focus = recipeLayout.getFocus();
    if (focus != null) {
        Object focusValue = focus.getValue();
        if (focusValue instanceof ItemStack) {
            ItemStack focused = (ItemStack) focusValue;
            List<ItemStack> paints = new ArrayList<ItemStack>();
            List<ItemStack> results = new ArrayList<ItemStack>();
            if (focus.getMode() == IFocus.Mode.OUTPUT) {
                // JEI is focusing on the output item. Limit the recipe to the fixed input item, the focused output item and the matching paint.
                IBlockState paint = PaintUtil.getSourceBlock(focused);
                ItemStack paintAsStack = PaintUtil.getPaintAsStack(paint);
                paints.add(paintAsStack);
                results.add(focused);
            } else if (stackHelper.isEquivalent(focused, currentRecipe.target)) {
                // between weird and wrong. So remove the recipe "item+item" from the list to get "anything+item=anything".
                for (int i = 0; i < currentRecipe.paints.size(); i++) {
                    ItemStack resultStack = currentRecipe.results.get(i);
                    ItemStack paintStack = currentRecipe.paints.get(i);
                    if (!stackHelper.isEquivalent(focused, paintStack)) {
                        paints.add(paintStack);
                        results.add(resultStack);
                    }
                }
            } else {
                // JEI is focusing on the paint. Limit the output items to things that are painted with this paint.
                for (ResultStack result : currentRecipe.recipe.getCompletedResult(focused, currentRecipe.target)) {
                    paints.add(focused);
                    results.add(result.item);
                }
            }
            if (!paints.isEmpty()) {
                guiItemStacks.set(1, paints);
                guiItemStacks.set(2, results);
                return;
            }
        }
    }
    guiItemStacks.set(0, currentRecipe.target);
    guiItemStacks.set(1, currentRecipe.paints);
    guiItemStacks.set(2, currentRecipe.results);
    group.set(ingredients);
}
Also used : EnergyIngredient(crazypants.enderio.base.integration.jei.energy.EnergyIngredient) IBlockState(net.minecraft.block.state.IBlockState) ResultStack(crazypants.enderio.base.recipe.IMachineRecipe.ResultStack) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 2 with EnergyIngredient

use of crazypants.enderio.base.integration.jei.energy.EnergyIngredient in project EnderIO by SleepyTrousers.

the class SoulBinderRecipeCategory method setRecipe.

@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull SoulBinderRecipeCategory.SoulBinderRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);
    guiItemStacks.init(0, true, 37 - xOff, 33 - yOff);
    guiItemStacks.init(1, true, 58 - xOff, 33 - yOff);
    guiItemStacks.init(2, false, 111 - xOff, 33 - yOff);
    guiItemStacks.init(3, false, 133 - xOff, 33 - yOff);
    group.init(xOff, true, EnergyIngredientRenderer.INSTANCE, 5, 35, 60, 10, 0, 0);
    guiItemStacks.set(ingredients);
    IFocus<?> focus = recipeLayout.getFocus();
    if (focus != null && focus.getMode() == Mode.INPUT && focus.getValue() instanceof ItemStack && ((ItemStack) focus.getValue()).getItem() == itemSoulVial.getItemNN() && CapturedMob.containsSoul(((ItemStack) focus.getValue())) && ingredients.getOutputs(ItemStack.class).get(1).size() > 1) {
        // we are focused on a filled soul vial on the input side and the output has a list
        final CapturedMob vialMob = CapturedMob.create(((ItemStack) focus.getValue()));
        if (vialMob != null) {
            List<ItemStack> newOutputs = new ArrayList<>();
            for (ItemStack output : ingredients.getOutputs(ItemStack.class).get(1)) {
                if (output != null && vialMob.isSameType(CapturedMob.create(output))) {
                    newOutputs.add(output);
                }
            }
            guiItemStacks.set(3, newOutputs);
        }
    }
    if (focus != null && focus.getMode() == Mode.OUTPUT && focus.getValue() instanceof ItemStack && CapturedMob.containsSoul(((ItemStack) focus.getValue())) && ingredients.getInputs(ItemStack.class).get(0).size() > 1 && ingredients.getOutputs(ItemStack.class).get(1).size() > 1) {
        // we are focused on a output item and the both sides have a list
        final CapturedMob resultMob = CapturedMob.create(((ItemStack) focus.getValue()));
        if (resultMob != null) {
            List<ItemStack> newInputs = new ArrayList<>();
            for (ItemStack input : ingredients.getInputs(ItemStack.class).get(0)) {
                if (input != null && resultMob.isSameType(CapturedMob.create(input))) {
                    newInputs.add(input);
                }
            }
            guiItemStacks.set(0, newInputs);
            guiItemStacks.set(3, ((ItemStack) focus.getValue()));
        }
    }
    group.set(ingredients);
}
Also used : EnergyIngredient(crazypants.enderio.base.integration.jei.energy.EnergyIngredient) CapturedMob(crazypants.enderio.util.CapturedMob) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EnergyIngredient

use of crazypants.enderio.base.integration.jei.energy.EnergyIngredient in project EnderIO by SleepyTrousers.

the class WeatherObeliskRecipeCategory method setRecipe.

@SuppressWarnings("null")
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull WeatherObeliskRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
    IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);
    guiItemStacks.init(0, true, 60, 4);
    fluidStacks.init(1, true, 3, 5, 16, 63, 8000, true, null);
    group.init(2, true, EnergyIngredientRenderer.INSTANCE, 27, 59, 60, 10, 0, 0);
    guiItemStacks.set(ingredients);
    fluidStacks.set(ingredients);
    group.set(ingredients);
}
Also used : EnergyIngredient(crazypants.enderio.base.integration.jei.energy.EnergyIngredient) IGuiFluidStackGroup(mezz.jei.api.gui.IGuiFluidStackGroup) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup)

Example 4 with EnergyIngredient

use of crazypants.enderio.base.integration.jei.energy.EnergyIngredient in project EnderIO by SleepyTrousers.

the class WiredChargerRecipeCategory method setRecipe.

@SuppressWarnings("null")
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull WiredChargerRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
    IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
    IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);
    guiItemStacks.init(0, true, 71, 12);
    guiItemStacks.init(1, false, 122, 12);
    group.init(2, true, EnergyIngredientRenderer.INSTANCE, 0, 16, 70, 10, 0, 0);
    guiItemStacks.set(ingredients);
    group.set(ingredients);
}
Also used : EnergyIngredient(crazypants.enderio.base.integration.jei.energy.EnergyIngredient) IGuiItemStackGroup(mezz.jei.api.gui.IGuiItemStackGroup)

Example 5 with EnergyIngredient

use of crazypants.enderio.base.integration.jei.energy.EnergyIngredient in project EnderIO by SleepyTrousers.

the class ZombieGeneratorRecipeCategory method setRecipe.

@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull ZombieGeneratorRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) {
    IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
    IGuiIngredientGroup<EnergyIngredient> group = recipeLayout.getIngredientsGroup(EnergyIngredient.class);
    guiFluidStacks.init(0, true, 80 - xOff, 21 - yOff, 16, 47, tankCapacity, true, null);
    guiFluidStacks.addTooltipCallback(new ITooltipCallback<FluidStack>() {

        @Override
        public void onTooltip(int slotIndex, boolean input, @Nonnull FluidStack ingredient, @Nonnull List<String> tooltip) {
            if (slotIndex != 0)
                return;
            tooltip.add(Lang.GUI_ZOMBGEN_MINREQ.get(LangFluid.MB(Math.round(ZombieGenConfig.minimumTankLevel.get() * tankCapacity))));
        }
    });
    group.init(1, false, EnergyIngredientRenderer.INSTANCE, 75, 3, 40, 10, 0, 0);
    guiFluidStacks.set(ingredients);
    group.set(ingredients);
}
Also used : EnergyIngredient(crazypants.enderio.base.integration.jei.energy.EnergyIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) IGuiFluidStackGroup(mezz.jei.api.gui.IGuiFluidStackGroup)

Aggregations

EnergyIngredient (crazypants.enderio.base.integration.jei.energy.EnergyIngredient)13 IGuiItemStackGroup (mezz.jei.api.gui.IGuiItemStackGroup)10 ItemStack (net.minecraft.item.ItemStack)6 ArrayList (java.util.ArrayList)5 IGuiFluidStackGroup (mezz.jei.api.gui.IGuiFluidStackGroup)4 List (java.util.List)3 RecipeOutput (crazypants.enderio.base.recipe.RecipeOutput)2 NNList (com.enderio.core.common.util.NNList)1 ResultStack (crazypants.enderio.base.recipe.IMachineRecipe.ResultStack)1 CapturedMob (crazypants.enderio.util.CapturedMob)1 IBlockState (net.minecraft.block.state.IBlockState)1 FluidStack (net.minecraftforge.fluids.FluidStack)1