Skip to content

Commit a190ae0

Browse files
committed
fix: šŸ› Fixed recipe restocking for recipes with many ingredient alternatives
1 parent 7e50b33 commit a190ae0

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

ā€Žgradle.propertiesā€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod_id=sophisticatedcore
77
mod_name=Sophisticated Core
88
mod_license=All Rights Reserved
99
mod_group_id=net.p3pp3rf1y
10-
mod_version=1.3.83
10+
mod_version=1.3.84
1111
sonar_project_key=sophisticatedcore:SophisticatedCore
1212
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedCore
1313

ā€Žsrc/main/java/net/p3pp3rf1y/sophisticatedcore/compat/recipeviewers/common/ClientRecipeHelper.javaā€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,28 @@
1313
import java.util.ArrayList;
1414
import java.util.Collections;
1515
import java.util.List;
16+
import java.util.Optional;
1617
import java.util.function.BiFunction;
1718
import java.util.function.Function;
1819

1920
public class ClientRecipeHelper {
2021
private ClientRecipeHelper() {
2122
}
2223

24+
public static Optional<Recipe<?>> getRecipe(ResourceLocation recipeId) {
25+
Minecraft minecraft = Minecraft.getInstance();
26+
ClientLevel level = minecraft.level;
27+
if (level == null) {
28+
return Optional.empty();
29+
}
30+
31+
return getRecipe(level.getRecipeManager(), recipeId);
32+
}
33+
34+
public static Optional<Recipe<?>> getRecipe(RecipeManager recipeManager, ResourceLocation recipeId) {
35+
return recipeManager.byKey(recipeId);
36+
}
37+
2338
public static <C extends Container, T extends Recipe<C>, U extends Recipe<C>, V> List<V> transformAllRecipesOfType(RecipeType<T> recipeType,
2439
Class<U> filterRecipeClass, Function<U, V> transformRecipe) {
2540
Minecraft minecraft = Minecraft.getInstance();

ā€Žsrc/main/java/net/p3pp3rf1y/sophisticatedcore/util/RecipeHelper.javaā€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ public static <T extends AbstractCookingRecipe> Optional<T> getCookingRecipe(Ite
322322
return getLevel().flatMap(w -> safeGetRecipeFor(recipeType, new RecipeWrapper(new ItemStackHandler(NonNullList.of(ItemStack.EMPTY, stack))), w, null));
323323
}
324324

325+
public static Optional<Recipe<?>> getRecipe(ResourceLocation recipeId) {
326+
return getLevel().flatMap(level -> level.getRecipeManager().byKey(recipeId));
327+
}
328+
325329
public static Set<CompactingShape> getItemCompactingShapes(ItemStack stack) {
326330
return getFromCache(cache -> cache.getItemCompactingShapes(stack), Collections.emptySet());
327331
}

0 commit comments

Comments
Ā (0)