Search in sources :

Example 1 with ProcessingOutput

use of com.simibubi.create.content.contraptions.processing.ProcessingOutput in project Create by Creators-of-Create.

the class SequencedAssemblyRecipe method rollResult.

private ItemStack rollResult() {
    float totalWeight = 0;
    for (ProcessingOutput entry : resultPool) totalWeight += entry.getChance();
    float number = Create.RANDOM.nextFloat() * totalWeight;
    for (ProcessingOutput entry : resultPool) {
        number -= entry.getChance();
        if (number < 0)
            return entry.getStack().copy();
    }
    return ItemStack.EMPTY;
}
Also used : ProcessingOutput(com.simibubi.create.content.contraptions.processing.ProcessingOutput)

Example 2 with ProcessingOutput

use of com.simibubi.create.content.contraptions.processing.ProcessingOutput in project Create by Creators-of-Create.

the class CreateRecipeCategory method addStochasticTooltip.

public static void addStochasticTooltip(IGuiItemStackGroup itemStacks, List<ProcessingOutput> results, int startIndex) {
    itemStacks.addTooltipCallback((slotIndex, input, ingredient, tooltip) -> {
        if (input)
            return;
        if (slotIndex < startIndex)
            return;
        ProcessingOutput output = results.get(slotIndex - startIndex);
        float chance = output.getChance();
        if (chance != 1)
            tooltip.add(1, Lang.translate("recipe.processing.chance", chance < 0.01 ? "<1" : (int) (chance * 100)).withStyle(ChatFormatting.GOLD));
    });
}
Also used : ProcessingOutput(com.simibubi.create.content.contraptions.processing.ProcessingOutput)

Example 3 with ProcessingOutput

use of com.simibubi.create.content.contraptions.processing.ProcessingOutput in project Create by Creators-of-Create.

the class CreateRecipeCategory method getRenderedSlot.

public static AllGuiTextures getRenderedSlot(Recipe<?> recipe, int index) {
    AllGuiTextures jeiSlot = AllGuiTextures.JEI_SLOT;
    if (!(recipe instanceof ProcessingRecipe))
        return jeiSlot;
    ProcessingRecipe<?> processingRecipe = (ProcessingRecipe<?>) recipe;
    List<ProcessingOutput> rollableResults = processingRecipe.getRollableResults();
    if (rollableResults.size() <= index)
        return jeiSlot;
    if (processingRecipe.getRollableResults().get(index).getChance() == 1)
        return jeiSlot;
    return AllGuiTextures.JEI_CHANCE_SLOT;
}
Also used : ProcessingRecipe(com.simibubi.create.content.contraptions.processing.ProcessingRecipe) AllGuiTextures(com.simibubi.create.foundation.gui.AllGuiTextures) ProcessingOutput(com.simibubi.create.content.contraptions.processing.ProcessingOutput)

Example 4 with ProcessingOutput

use of com.simibubi.create.content.contraptions.processing.ProcessingOutput in project Create by Creators-of-Create.

the class MillingCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, AbstractCrushingRecipe recipe, IIngredients ingredients) {
    IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
    itemStacks.init(0, true, 14, 8);
    itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getItems()));
    List<ProcessingOutput> results = recipe.getRollableResults();
    boolean single = results.size() == 1;
    for (int outputIndex = 0; outputIndex < results.size(); outputIndex++) {
        int xOffset = outputIndex % 2 == 0 ? 0 : 19;
        int yOffset = (outputIndex / 2) * -19;
        itemStacks.init(outputIndex + 1, false, single ? 139 : 133 + xOffset, 27 + yOffset);
        itemStacks.set(outputIndex + 1, results.get(outputIndex).getStack());
    }
    addStochasticTooltip(itemStacks, results);
}
Also used : IGuiItemStackGroup(mezz.jei.api.gui.ingredient.IGuiItemStackGroup) ProcessingOutput(com.simibubi.create.content.contraptions.processing.ProcessingOutput)

Example 5 with ProcessingOutput

use of com.simibubi.create.content.contraptions.processing.ProcessingOutput in project Create by Creators-of-Create.

the class MysteriousItemConversionCategory method setRecipe.

@Override
public void setRecipe(IRecipeLayout recipeLayout, ConversionRecipe recipe, IIngredients ingredients) {
    IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
    List<ProcessingOutput> results = recipe.getRollableResults();
    itemStacks.init(0, true, 26, 16);
    itemStacks.set(0, Arrays.asList(recipe.getIngredients().get(0).getItems()));
    itemStacks.init(1, false, 131, 16);
    itemStacks.set(1, results.get(0).getStack());
}
Also used : IGuiItemStackGroup(mezz.jei.api.gui.ingredient.IGuiItemStackGroup) ProcessingOutput(com.simibubi.create.content.contraptions.processing.ProcessingOutput)

Aggregations

ProcessingOutput (com.simibubi.create.content.contraptions.processing.ProcessingOutput)9 IGuiItemStackGroup (mezz.jei.api.gui.ingredient.IGuiItemStackGroup)6 ProcessingRecipe (com.simibubi.create.content.contraptions.processing.ProcessingRecipe)1 AllGuiTextures (com.simibubi.create.foundation.gui.AllGuiTextures)1