Skip to content

Commit

Permalink
Merge pull request #2 from pietro-lopes/main
Browse files Browse the repository at this point in the history
fix: copy stack from ingredient before modifying it
  • Loading branch information
MichaelHillcox authored Nov 16, 2024
2 parents 96c9c43 + 44a8260 commit 73fc783
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 73fc783

Please sign in to comment.