Search in sources :

Example 1 with IRecipeSlotBuilder

use of mezz.jei.api.gui.builder.IRecipeSlotBuilder in project Botania by VazkiiMods.

the class PureDaisyRecipeCategory method setRecipe.

// todo fluid input rendering is probably kinda janky with waterlogged blocks. Might be worth getting rid of it entirely and only checking for full fluid blocks
@Override
public void setRecipe(@Nonnull IRecipeLayoutBuilder builder, @Nonnull IPureDaisyRecipe recipe, @Nonnull IFocusGroup focusGroup) {
    StateIngredient input = recipe.getInput();
    IRecipeSlotBuilder inputSlotBuilder = builder.addSlot(RecipeIngredientRole.INPUT, 9, 12).setFluidRenderer(1000, false, 16, 16);
    for (var state : input.getDisplayed()) {
        if (!state.getFluidState().isEmpty()) {
            inputSlotBuilder.addIngredient(VanillaTypes.FLUID, new FluidStack(state.getFluidState().getType(), 1000));
        }
    }
    inputSlotBuilder.addItemStacks(input.getDisplayedStacks()).addTooltipCallback((view, tooltip) -> tooltip.addAll(input.descriptionTooltip()));
    builder.addSlot(RecipeIngredientRole.CATALYST, 39, 12).addItemStack(new ItemStack(ModSubtiles.pureDaisy));
    Block outBlock = recipe.getOutputState().getBlock();
    FluidState outFluid = outBlock.defaultBlockState().getFluidState();
    if (!outFluid.isEmpty()) {
        builder.addSlot(RecipeIngredientRole.OUTPUT, 68, 12).setFluidRenderer(1000, false, 16, 16).addIngredient(VanillaTypes.FLUID, new FluidStack(outFluid.getType(), 1000));
    } else {
        if (outBlock.asItem() != Items.AIR) {
            builder.addSlot(RecipeIngredientRole.OUTPUT, 68, 12).addItemStack(new ItemStack(outBlock));
        }
    }
}
Also used : StateIngredient(vazkii.botania.api.recipe.StateIngredient) FluidStack(net.minecraftforge.fluids.FluidStack) Block(net.minecraft.world.level.block.Block) IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder) ItemStack(net.minecraft.world.item.ItemStack) FluidState(net.minecraft.world.level.material.FluidState)

Example 2 with IRecipeSlotBuilder

use of mezz.jei.api.gui.builder.IRecipeSlotBuilder in project RoughlyEnoughItems by shedaniel.

the class JEIRecipeLayoutBuilder method addSlot.

public IRecipeSlotBuilder addSlot(RecipeIngredientRole role, int x, int y, int index) {
    if (index == -1) {
        index = getNextId(slots.stream().map(JEIRecipeSlot::getIndex).filter(integer -> integer >= 0).collect(Collectors.toSet()));
    }
    JEIRecipeSlot slot = new JEIRecipeSlot(index, role, new Point(x, y));
    if (rolePredicate != null && !rolePredicate.test(role))
        return slot;
    slots.add(slot);
    markDirty();
    return slot;
}
Also used : Point(me.shedaniel.math.Point) List(java.util.List) IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder) Predicate(java.util.function.Predicate) RecipeIngredientRole(mezz.jei.api.recipe.RecipeIngredientRole) IRecipeLayoutBuilder(mezz.jei.api.gui.builder.IRecipeLayoutBuilder) Set(java.util.Set) InternalLogger(me.shedaniel.rei.impl.common.InternalLogger) Collectors(java.util.stream.Collectors) IIngredientAcceptor(mezz.jei.api.gui.builder.IIngredientAcceptor) ArrayList(java.util.ArrayList) Point(me.shedaniel.math.Point)

Example 3 with IRecipeSlotBuilder

use of mezz.jei.api.gui.builder.IRecipeSlotBuilder in project Beyond-Earth by MrScautHD.

the class JeiPlugin method placeRocketParts.

public static void placeRocketParts(int left, int top, int mod, IPlacer placer, RocketPart part, IRecipeLayoutBuilder builder, WorkbenchingRecipe recipe) {
    List<Ingredient> ingredients = recipe.getParts().get(part);
    RocketPartGridPlacer.place(left, top, mod, placer, part, (i, bounds) -> {
        Ingredient ingredient = (ingredients != null && i < ingredients.size()) ? ingredients.get(i) : Ingredient.EMPTY;
        IRecipeSlotBuilder slot = builder.addSlot(RecipeIngredientRole.INPUT, bounds.getX(), bounds.getY());
        slot.addIngredients(ingredient);
    });
}
Also used : Ingredient(net.minecraft.world.item.crafting.Ingredient) IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder)

Example 4 with IRecipeSlotBuilder

use of mezz.jei.api.gui.builder.IRecipeSlotBuilder in project TerraFirmaCraft by TerraFirmaCraft.

the class AlloyRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayoutBuilder builder, AlloyRecipe recipe, IFocusGroup focuses) {
    IRecipeSlotBuilder fluidOutput = builder.addSlot(RecipeIngredientRole.OUTPUT, 149, maxHeight / 2 - slot.getHeight() / 2 + 1);
    int[] positions = getPositions(recipe.getRanges());
    int iteration = 0;
    for (Metal metal : recipe.getRanges().keySet()) {
        int x = (iteration % 2 == 0 ? firstColumnX : secondColumnX) + 1;
        int y = positions[Math.floorDiv(iteration, 2)] + 1;
        IRecipeSlotBuilder liquidSlot = builder.addSlot(RecipeIngredientRole.INPUT, x, y);
        liquidSlot.addIngredient(VanillaTypes.FLUID, new FluidStack(metal.getFluid(), 1000));
        iteration++;
    }
    fluidOutput.addIngredient(VanillaTypes.FLUID, new FluidStack(recipe.getResult().getFluid(), 1000));
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder) Metal(net.dries007.tfc.util.Metal)

Example 5 with IRecipeSlotBuilder

use of mezz.jei.api.gui.builder.IRecipeSlotBuilder in project TerraFirmaCraft by TerraFirmaCraft.

the class AnvilRecipeCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayoutBuilder builder, AnvilRecipe recipe, IFocusGroup focuses) {
    IRecipeSlotBuilder inputSlot = builder.addSlot(RecipeIngredientRole.INPUT, 6, 5);
    IRecipeSlotBuilder outputSlot = builder.addSlot(RecipeIngredientRole.OUTPUT, 76, 5);
    inputSlot.addIngredients(recipe.getInput());
    outputSlot.addItemStack(recipe.getResultItem());
}
Also used : IRecipeSlotBuilder(mezz.jei.api.gui.builder.IRecipeSlotBuilder)

Aggregations

IRecipeSlotBuilder (mezz.jei.api.gui.builder.IRecipeSlotBuilder)18 ItemStack (net.minecraft.world.item.ItemStack)4 FluidStack (net.minecraftforge.fluids.FluidStack)4 List (java.util.List)2 Ingredient (net.minecraft.world.item.crafting.Ingredient)2 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 LootDrop (jeresources.api.drop.LootDrop)1 Point (me.shedaniel.math.Point)1 InternalLogger (me.shedaniel.rei.impl.common.InternalLogger)1 IIngredientAcceptor (mezz.jei.api.gui.builder.IIngredientAcceptor)1 IRecipeLayoutBuilder (mezz.jei.api.gui.builder.IRecipeLayoutBuilder)1 RecipeIngredientRole (mezz.jei.api.recipe.RecipeIngredientRole)1 SimplePotRecipe (net.dries007.tfc.common.recipes.SimplePotRecipe)1 Metal (net.dries007.tfc.util.Metal)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 Block (net.minecraft.world.level.block.Block)1 FluidState (net.minecraft.world.level.material.FluidState)1