Skip to content

Commit

Permalink
fix: copy stack from ingredient before modifying it
Browse files Browse the repository at this point in the history
  • Loading branch information
pietro-lopes committed Nov 11, 2024
1 parent 96c9c43 commit 44a8260
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
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()) {
return Ingredient.EMPTY;
}

Ingredient ingredient = stack.getIngredient();
ItemStack[] items = ingredient.getItems();
for (ItemStack item : items) {
item.setCount(stack.getAmount());
}
Stream<ItemStack> stacks = Arrays.stream(ingredient.getItems()).map(oldStack -> oldStack.copyWithCount(stack.getAmount()));

return Ingredient.of(items);
return Ingredient.of(stacks);
}
}

0 comments on commit 44a8260

Please sign in to comment.