Skip to content

Commit

Permalink
fix mixing vat recipes not loading all ingredients
Browse files Browse the repository at this point in the history
  • Loading branch information
Hojosa committed Apr 4, 2024
1 parent 468ae28 commit 6da6738
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 7 additions & 11 deletions src/main/java/growthcraft/milk/recipe/MixingVatFluidRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
Expand Down Expand Up @@ -145,14 +145,10 @@ public boolean activationToolValid(ItemStack tool) {
return this.ingredients;
}

public List<ItemStack> getIngredientList() {
return Arrays.stream(ingredients.get(0).getItems()).toList();
}

public List<Item> getIngredientItems() {
List<Item> ingredientItems = new ArrayList<>();
this.getIngredientList().forEach(
itemStack -> ingredientItems.add(itemStack.getItem())
this.getIngredients().forEach(
itemStack -> ingredientItems.add(itemStack.getItems()[0].getItem())
);
return ingredientItems;
}
Expand Down Expand Up @@ -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);
Expand Down
25 changes: 11 additions & 14 deletions src/main/java/growthcraft/milk/recipe/MixingVatItemRecipe.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<SimpleContainer> {

Expand Down Expand Up @@ -67,11 +68,11 @@ public boolean matches(FluidStack testFluidStack, List<ItemStack> 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++;
}
}
Expand Down Expand Up @@ -102,10 +103,6 @@ public int getProcessingTime() {
return this.ingredients;
}

public List<ItemStack> getIngredientList() {
return Arrays.stream(ingredients.get(0).getItems()).toList();
}

public ItemStack getResultItemStack() {
return this.resultItemStack.copy();
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 6da6738

Please sign in to comment.