From 44a826052179e9b4f2763816c4295e04aa86a87d Mon Sep 17 00:00:00 2001 From: pietro-lopes <97140255+pietro-lopes@users.noreply.github.com> Date: Mon, 11 Nov 2024 00:31:23 -0300 Subject: [PATCH] fix: copy stack from ingredient before modifying it --- .../mods/ftbjeiextras/modspecific/GlodiumHelpers.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/ftb/mods/ftbjeiextras/modspecific/GlodiumHelpers.java b/src/main/java/dev/ftb/mods/ftbjeiextras/modspecific/GlodiumHelpers.java index 7163d0f..840f0ac 100644 --- a/src/main/java/dev/ftb/mods/ftbjeiextras/modspecific/GlodiumHelpers.java +++ b/src/main/java/dev/ftb/mods/ftbjeiextras/modspecific/GlodiumHelpers.java @@ -4,6 +4,9 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; +import java.util.Arrays; +import java.util.stream.Stream; + public class GlodiumHelpers { public static Ingredient of(IngredientStack.Item stack) { if (stack.isEmpty()) { @@ -11,11 +14,8 @@ public static Ingredient of(IngredientStack.Item stack) { } Ingredient ingredient = stack.getIngredient(); - ItemStack[] items = ingredient.getItems(); - for (ItemStack item : items) { - item.setCount(stack.getAmount()); - } + Stream stacks = Arrays.stream(ingredient.getItems()).map(oldStack -> oldStack.copyWithCount(stack.getAmount())); - return Ingredient.of(items); + return Ingredient.of(stacks); } }