Skip to content

Commit b458c7f

Browse files
committed
feat: fix recipe update
1 parent 00e65a3 commit b458c7f

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/main/java/me/matl114/hacks/RecipeTasks.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import java.util.*;
1414
import java.util.function.Consumer;
15+
import java.util.stream.Stream;
1516

1617
public class RecipeTasks {
1718
private static MinecraftClient mc = MinecraftClient.getInstance();
@@ -78,6 +79,19 @@ public RecipeIngredient[] ingredient() {
7879
}
7980

8081
}
82+
83+
public static List<Ingredient> getIngredients(Recipe<?> recipe){
84+
return recipe.getIngredients();
85+
}
86+
87+
public static Stream<ItemStack> streamIngredientOptions(Ingredient ingredient){
88+
return Arrays.stream(ingredient.getMatchingStacks());
89+
}
90+
91+
public static List<Ingredient> getIngredients(RecipeEntry<?> recipeEntry){
92+
return recipeEntry.value().getIngredients();
93+
}
94+
8195
static{
8296
// Listener.getServerDisconnectPoint().registerHandler((v)->{
8397
// resetCache();

src/main/java/me/matl114/hacks/SlimefunTasks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,13 @@ public static RecipeIngredient[] transfer3x3RecipeDisplay(Recipe<?> instance, Re
310310
RecipeIngredient[] ingredients = new RecipeIngredient[9];
311311

312312
if(instance instanceof ShapedRecipe shaped){
313-
List<Ingredient> raw = shaped.getIngredients();
313+
List<Ingredient> raw = RecipeTasks.getIngredients(shaped);
314314
int width = shaped.getWidth();
315315
int height = shaped.getHeight();
316316
for (int i=0; i< 3; ++i){
317317
for(int j = 0; j< 3; ++j){
318318
if(i < height && j < width){
319-
ingredients[3*i + j] = new RecipeIngredient( raw.get(width * i + j).getMatchingStacks());
319+
ingredients[3*i + j] = new RecipeIngredient(RecipeTasks.streamIngredientOptions(raw.get(width * i + j)).toArray(ItemStack[]::new));
320320
}else {
321321
ingredients[3*i + j] = RecipeIngredient.EMPTY;
322322
}

src/main/java/me/matl114/hacks/modules/inv/FastCraft.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import me.matl114.gui.basic.*;
77
import me.matl114.gui.other.TradeInformationSubScreen;
88
import me.matl114.hacks.InvTasks;
9+
import me.matl114.hacks.RecipeTasks;
910
import me.matl114.hacks.api.BaseModule;
1011
import me.matl114.managers.Configs;
1112
import me.matl114.managers.TaskManagers;
@@ -102,8 +103,8 @@ public void placeLastCraftingRecipe(HandledScreen<? extends AbstractRecipeScreen
102103
mc.interactionManager.clickRecipe(craftingScreen.getScreenHandler().syncId, last,true);
103104
if(doCraft){
104105
int maxCraft = 64;
105-
for (Ingredient material:last.value().getIngredients()){
106-
for (ItemStack val:material.getMatchingStacks()){
106+
for (Ingredient material : RecipeTasks.getIngredients(last)){
107+
for (ItemStack val : RecipeTasks.streamIngredientOptions(material).toList()){
107108
maxCraft = Math.min(maxCraft, val.getMaxCount());
108109
}
109110
}

0 commit comments

Comments
 (0)