mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-25 14:34:54 +00:00
Recipe Group Optimization (#1054)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
9f3697bb67
commit
a685efb3b7
11 files changed
+654
-214
No files matched your search
@@ -4,6 +4,7 @@ import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -35,6 +36,7 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
public static GuiRecipe<?> createRecipeGui(String outputId, boolean open, Object... results) {
|
||||
final Minecraft mc = NEIClientUtils.mc();
|
||||
final RecipeId recipeId;
|
||||
List<ItemStack> pinnedIngredients = null;
|
||||
|
||||
for (int i = 0; i < results.length; i++) {
|
||||
if (results[i] instanceof ItemStack stack) {
|
||||
@@ -46,6 +48,12 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
recipeId = getRecipeId(mc.currentScreen, (ItemStack) results[0]);
|
||||
} else if ("recipeId".equals(outputId)) {
|
||||
recipeId = (RecipeId) results[1];
|
||||
|
||||
// optional third argument: ingredients to pin the found recipe with
|
||||
if (results.length > 2 && results[2] instanceof List<?>list) {
|
||||
pinnedIngredients = extractIngredients(list);
|
||||
}
|
||||
|
||||
} else {
|
||||
recipeId = getCurrentRecipeId(mc.currentScreen);
|
||||
}
|
||||
@@ -65,13 +73,25 @@ public class GuiCraftingRecipe extends GuiRecipe<ICraftingHandler> {
|
||||
mc.displayGuiScreen(gui);
|
||||
}
|
||||
|
||||
gui.openTargetRecipe(recipeId);
|
||||
gui.openTargetRecipe(recipeId, pinnedIngredients);
|
||||
return gui;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static List<ItemStack> extractIngredients(List<?> list) {
|
||||
final List<ItemStack> ingredients = new ArrayList<>(list.size());
|
||||
|
||||
for (Object item : list) {
|
||||
if (item instanceof ItemStack stack) {
|
||||
ingredients.add(stack);
|
||||
}
|
||||
}
|
||||
|
||||
return ingredients;
|
||||
}
|
||||
|
||||
public static ArrayList<ICraftingHandler> getCraftingHandlers(String outputId, Object... results) {
|
||||
ArrayList<ICraftingHandler> craftinghandlers = GuiCraftingRecipe.craftinghandlers;
|
||||
ArrayList<ICraftingHandler> serialCraftingHandlers = GuiCraftingRecipe.serialCraftingHandlers;
|
||||
|
||||
Reference in new issue
Block a user