From 6da673817630467e3ed21071f2cfc3ebd6060500 Mon Sep 17 00:00:00 2001 From: Fox Date: Thu, 4 Apr 2024 15:00:38 +0200 Subject: [PATCH] fix mixing vat recipes not loading all ingredients --- .../MixingVatRecipeFluidCategory.java | 4 +-- .../category/MixingVatRecipeItemCategory.java | 4 +-- .../milk/recipe/MixingVatFluidRecipe.java | 18 ++++++------- .../milk/recipe/MixingVatItemRecipe.java | 25 ++++++++----------- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeFluidCategory.java b/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeFluidCategory.java index 33b0600c..37e27fbf 100644 --- a/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeFluidCategory.java +++ b/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeFluidCategory.java @@ -75,12 +75,12 @@ public MixingVatRecipeFluidCategory(IGuiHelper guiHelper) { @Override public void setRecipe(@NotNull IRecipeLayoutBuilder builder, MixingVatFluidRecipe recipe, @NotNull IFocusGroup focuses) { - int ingredientCount = recipe.getIngredientList().size(); + int ingredientCount = recipe.getIngredients().size(); // Input Inventory for(int i = 0; i < ingredientCount; i++) { builder.addSlot(RecipeIngredientRole.INPUT, 61, 8 + ( i * 16)) - .addItemStack(recipe.getIngredientList().get(i)); + .addIngredients(recipe.getIngredients().get(i)); } // Fluid Tank 0 diff --git a/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeItemCategory.java b/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeItemCategory.java index 2f87790f..923502d6 100644 --- a/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeItemCategory.java +++ b/src/main/java/growthcraft/milk/compat/jei/category/MixingVatRecipeItemCategory.java @@ -75,12 +75,12 @@ public MixingVatRecipeItemCategory(IGuiHelper guiHelper) { @Override public void setRecipe(@NotNull IRecipeLayoutBuilder builder, MixingVatItemRecipe recipe, @NotNull IFocusGroup focuses) { - int ingredientCount = recipe.getIngredientList().size(); + int ingredientCount = recipe.getIngredients().size(); // Input Inventory for (int i = 0; i < ingredientCount; i++) { builder.addSlot(RecipeIngredientRole.INPUT, 61, 8 + (i * 18)) - .addItemStack(recipe.getIngredientList().get(i)); + .addIngredients(recipe.getIngredients().get(i)); } // Fluid Tank 1 diff --git a/src/main/java/growthcraft/milk/recipe/MixingVatFluidRecipe.java b/src/main/java/growthcraft/milk/recipe/MixingVatFluidRecipe.java index 45bacc4e..eaaa51d4 100644 --- a/src/main/java/growthcraft/milk/recipe/MixingVatFluidRecipe.java +++ b/src/main/java/growthcraft/milk/recipe/MixingVatFluidRecipe.java @@ -74,11 +74,11 @@ public boolean matches(FluidStack testBaseFluidStack, FluidStack testReagentFlui boolean ingredientMatches = false; if (this.getIngredients().size() == testIngredients.size()) { - int itemCount = this.getIngredientList().size(); + int itemCount = this.getIngredients().size(); int matchCount = 0; - for (int i = 0; i < this.getIngredientList().size(); i++) { - if (this.getIngredientList().get(i).getItem() == testIngredients.get(i).getItem() && - this.getIngredientList().get(i).getCount() == testIngredients.get(i).getCount()) { + for (int i = 0; i < this.getIngredients().size(); i++) { + if (this.getIngredients().get(i).getItems()[0].getItem() == testIngredients.get(i).getItem() && + this.getIngredients().get(i).getItems()[0].getCount() == testIngredients.get(i).getCount()) { matchCount++; } } @@ -145,14 +145,10 @@ public boolean activationToolValid(ItemStack tool) { return this.ingredients; } - public List getIngredientList() { - return Arrays.stream(ingredients.get(0).getItems()).toList(); - } - public List getIngredientItems() { List ingredientItems = new ArrayList<>(); - this.getIngredientList().forEach( - itemStack -> ingredientItems.add(itemStack.getItem()) + this.getIngredients().forEach( + itemStack -> ingredientItems.add(itemStack.getItems()[0].getItem()) ); return ingredientItems; } @@ -261,7 +257,7 @@ public void toNetwork(FriendlyByteBuf buffer, MixingVatFluidRecipe recipe) { buffer.writeFluidStack(recipe.getInputFluidStack()); buffer.writeItemStack(recipe.getActivationTool(), false); - buffer.writeVarInt(recipe.getIngredientList().size()); + buffer.writeVarInt(recipe.getIngredients().size()); for (Ingredient ingredient : recipe.getIngredients()) { ingredient.toNetwork(buffer); diff --git a/src/main/java/growthcraft/milk/recipe/MixingVatItemRecipe.java b/src/main/java/growthcraft/milk/recipe/MixingVatItemRecipe.java index c6f4daef..32741508 100644 --- a/src/main/java/growthcraft/milk/recipe/MixingVatItemRecipe.java +++ b/src/main/java/growthcraft/milk/recipe/MixingVatItemRecipe.java @@ -1,6 +1,12 @@ package growthcraft.milk.recipe; +import java.util.List; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import com.google.gson.JsonObject; + import growthcraft.lib.utils.CraftingUtils; import growthcraft.lib.utils.RecipeUtils; import growthcraft.milk.GrowthcraftMilk; @@ -19,11 +25,6 @@ import net.minecraft.world.level.Level; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Arrays; -import java.util.List; public class MixingVatItemRecipe implements Recipe { @@ -67,11 +68,11 @@ public boolean matches(FluidStack testFluidStack, List testIngredient boolean ingredientMatches = false; if (this.getIngredients().size() == testIngredients.size()) { - int itemCount = this.getIngredientList().size(); + int itemCount = this.getIngredients().size(); int matchCount = 0; - for (int i = 0; i < this.getIngredientList().size(); i++) { - if (this.getIngredientList().get(i).getItem() == testIngredients.get(i).getItem() && - this.getIngredientList().get(i).getCount() == testIngredients.get(i).getCount()) { + for (int i = 0; i < this.getIngredients().size(); i++) { + if (this.getIngredients().get(i).getItems()[0].getItem() == testIngredients.get(i).getItem() && + this.getIngredients().get(i).getItems()[0].getCount() == testIngredients.get(i).getCount()) { matchCount++; } } @@ -102,10 +103,6 @@ public int getProcessingTime() { return this.ingredients; } - public List getIngredientList() { - return Arrays.stream(ingredients.get(0).getItems()).toList(); - } - public ItemStack getResultItemStack() { return this.resultItemStack.copy(); } @@ -243,7 +240,7 @@ public void toNetwork(FriendlyByteBuf buffer, MixingVatItemRecipe recipe) { buffer.writeFluidStack(recipe.getInputFluidStack()); buffer.writeItemStack(recipe.getActivationTool(), false); - buffer.writeVarInt(recipe.getIngredientList().size()); + buffer.writeVarInt(recipe.getIngredients().size()); for (Ingredient ingredient : recipe.getIngredients()) { ingredient.toNetwork(buffer);