diff options
Diffstat (limited to 'src/main/java/lv/enes/mc/eris_alchemy/recipe/SimplifiedRecipe.java')
| -rw-r--r-- | src/main/java/lv/enes/mc/eris_alchemy/recipe/SimplifiedRecipe.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/lv/enes/mc/eris_alchemy/recipe/SimplifiedRecipe.java b/src/main/java/lv/enes/mc/eris_alchemy/recipe/SimplifiedRecipe.java index 518cf89..b63e4c5 100644 --- a/src/main/java/lv/enes/mc/eris_alchemy/recipe/SimplifiedRecipe.java +++ b/src/main/java/lv/enes/mc/eris_alchemy/recipe/SimplifiedRecipe.java | |||
| @@ -28,7 +28,12 @@ import java.util.function.Predicate; | |||
| 28 | import java.util.function.Supplier; | 28 | import java.util.function.Supplier; |
| 29 | import java.util.stream.Stream; | 29 | import java.util.stream.Stream; |
| 30 | 30 | ||
| 31 | public record SimplifiedRecipe(ItemStack output, List<ItemStack> remainder, List<Supplier<Ingredient>> input) { | 31 | public record SimplifiedRecipe( |
| 32 | ItemStack output, | ||
| 33 | List<ItemStack> remainder, | ||
| 34 | List<Supplier<Ingredient>> input, | ||
| 35 | boolean fromChipped | ||
| 36 | ) { | ||
| 32 | public static List<SimplifiedRecipe> of(Recipe<?> recipe, RegistryAccess registryAccess) { | 37 | public static List<SimplifiedRecipe> of(Recipe<?> recipe, RegistryAccess registryAccess) { |
| 33 | if (ForeignUtils.isClassAvailable("earth.terrarium.chipped.common.recipes.ChippedRecipe") | 38 | if (ForeignUtils.isClassAvailable("earth.terrarium.chipped.common.recipes.ChippedRecipe") |
| 34 | && recipe instanceof ChippedRecipe chippedRecipe) { | 39 | && recipe instanceof ChippedRecipe chippedRecipe) { |
| @@ -46,10 +51,10 @@ public record SimplifiedRecipe(ItemStack output, List<ItemStack> remainder, List | |||
| 46 | .toList(); | 51 | .toList(); |
| 47 | var outputs = items.stream().filter(isOutput).map(Item::getDefaultInstance).toList(); | 52 | var outputs = items.stream().filter(isOutput).map(Item::getDefaultInstance).toList(); |
| 48 | return outputs.stream() | 53 | return outputs.stream() |
| 49 | .flatMap( | 54 | .flatMap(output -> |
| 50 | output -> | 55 | inputs.stream() |
| 51 | inputs.stream() | 56 | .map(input -> |
| 52 | .map(input -> new SimplifiedRecipe(output, remainder, input)) | 57 | new SimplifiedRecipe(output, remainder, input, true)) |
| 53 | ); | 58 | ); |
| 54 | }) | 59 | }) |
| 55 | .toList(); | 60 | .toList(); |
| @@ -62,7 +67,8 @@ public record SimplifiedRecipe(ItemStack output, List<ItemStack> remainder, List | |||
| 62 | .stream() | 67 | .stream() |
| 63 | .filter(ingredient -> !ingredient.isEmpty()) | 68 | .filter(ingredient -> !ingredient.isEmpty()) |
| 64 | .map(x -> (Supplier<Ingredient>)() -> x) | 69 | .map(x -> (Supplier<Ingredient>)() -> x) |
| 65 | .toList() | 70 | .toList(), |
| 71 | false | ||
| 66 | )); | 72 | )); |
| 67 | } | 73 | } |
| 68 | 74 | ||
| @@ -110,7 +116,7 @@ public record SimplifiedRecipe(ItemStack output, List<ItemStack> remainder, List | |||
| 110 | var output = parseOutputOrRemainder(obj.get("output")); | 116 | var output = parseOutputOrRemainder(obj.get("output")); |
| 111 | var remainder = parseRemainders(obj.get("remainder")); | 117 | var remainder = parseRemainders(obj.get("remainder")); |
| 112 | var input = parseInputs(obj.get("input")); | 118 | var input = parseInputs(obj.get("input")); |
| 113 | return new SimplifiedRecipe(output, remainder, input); | 119 | return new SimplifiedRecipe(output, remainder, input, false); |
| 114 | } | 120 | } |
| 115 | 121 | ||
| 116 | private List<Supplier<Ingredient>> parseInputs(JsonElement el) { | 122 | private List<Supplier<Ingredient>> parseInputs(JsonElement el) { |