Skip to content

Commit

Permalink
Fix REI compat: Display recipes for items not in primary output (#1168)
Browse files Browse the repository at this point in the history
- Enhanced `CreateDisplay` to capture recipes where the searched item is a secondary, tertiary, etc., output.
  • Loading branch information
sarim authored Dec 8, 2023
1 parent 9788720 commit e4d6e78
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import com.simibubi.create.content.processing.recipe.ProcessingOutput;
import com.simibubi.create.content.processing.recipe.ProcessingRecipe;

import me.shedaniel.rei.api.common.category.CategoryIdentifier;
import me.shedaniel.rei.api.common.display.Display;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;

public class CreateDisplay<R extends Recipe<?>> implements Display {
Expand All @@ -23,8 +28,21 @@ public CreateDisplay(R recipe, CategoryIdentifier<CreateDisplay<R>> id, List<Ent
}

public CreateDisplay(R recipe, CategoryIdentifier<CreateDisplay<R>> id) {
this(recipe, id, EntryIngredients.ofIngredients(recipe.getIngredients()), Collections.singletonList(EntryIngredients.of(recipe.getResultItem())));
this.uid = id;
this.recipe = recipe;

this.input = EntryIngredients.ofIngredients(recipe.getIngredients());

if (recipe instanceof ProcessingRecipe) {
this.output = ((List<ItemStack>)((ProcessingRecipe) recipe).getRollableResultsAsItemStacks()).stream()
.map(EntryIngredients::of)
.collect(Collectors.toList());
} else {
this.output = Collections.singletonList(EntryIngredients.of(recipe.getResultItem()));
}
}



public R getRecipe() {
return recipe;
Expand Down

0 comments on commit e4d6e78

Please sign in to comment.