Skip to content

Core Recipe Structure

InWorldRecipe

The core recipe class, implementing Recipe<InWorldRecipeContext> and IPrioritized.

Constructor Parameters

ParameterTypeDescription
iconItemStackTemplateRecipe icon (displayed in JEI / recipe book)
triggerIRecipeTriggerTrigger condition
conflictingList<IRecipePredicate<?>>Conflicting predicates (consuming match; prevents other recipes after consumption)
nonConflictingList<IRecipePredicate<?>>Non-conflicting predicates (check only, no consumption)
outcomesList<IRecipeOutcome<?>>Outcome list
priorityintPriority (lower number = higher priority), can be auto-calculated
compatiblebooleanCompatible mode (true allows multiple recipes to share inputs)
maxEfficiencyintMaximum executions per trigger; default Integer.MAX_VALUE

Constructor Overloads

java
// Full constructor
new InWorldRecipe(icon, trigger, conflicting, nonConflicting, outcomes, priority, compatible, maxEfficiency);

// Omit maxEfficiency (default Integer.MAX_VALUE)
new InWorldRecipe(icon, trigger, conflicting, nonConflicting, outcomes, priority, compatible);

// Auto-calculate priority
new InWorldRecipe(icon, trigger, conflicting, nonConflicting, outcomes, compatible, maxEfficiency);
new InWorldRecipe(icon, trigger, conflicting, nonConflicting, outcomes, compatible);

Core Methods

MethodDescription
matches(InWorldRecipeContext, Level)First checks non-conflicting predicates (ShapelessMatcher.compatible), then conflicting predicates (compatible mode uses compatible, non-compatible uses incompatible). On failure, clears the predicate stack.
assemble(InWorldRecipeContext)Pops and consumes conflicting predicates in order, executes all outcomes by probability, returns the icon ItemStack
getSerializer()Returns LibRecipeTypes.IN_WORLD_RECIPE_SERIALIZER
getType()Returns LibRecipeTypes.IN_WORLD_RECIPE

Automatic Priority Calculation

calcPriority(trigger, conflicting, nonConflicting, outcomes) sums the priority values of the trigger, all predicates, and all outcomes.

Serialization

InWorldRecipe.Serializer provides CODEC (MapCodec<InWorldRecipe>) and STREAM_CODEC.

JSON Fields:

FieldTypeDefaultDescription
iconItemStackTemplateminecraft:anvilRecipe icon
triggerIdentifier--Trigger registry ID
conflictingIRecipePredicate[]--Conflicting predicate list
non_conflictingIRecipePredicate[]--Non-conflicting predicate list
outcomesIRecipeOutcome[]--Outcome list
priorityint1Priority
compatiblebooltrueCompatible mode
max_efficiencyint2147483647Max efficiency

Getters

java
public ItemStackTemplate icon();
public IRecipeTrigger trigger();
public List<IRecipePredicate<?>> conflicting();
public List<IRecipePredicate<?>> nonConflicting();
public List<IRecipeOutcome<?>> outcomes();
public int priority();
public boolean compatible();
public int maxEfficiency();

Usage Example

java
InWorldRecipe recipe = new InWorldRecipe(
    new ItemStackTemplate(Items.CRAFTING_TABLE),
    trigger,
    List.of(hasItemPredicate),
    List.of(hasBlockPredicate),
    List.of(spawnItemOutcome),
    true  // compatible
);

Released under the CC-BY-NC-SA 4.0 License.