Skip to content

Commit

Permalink
Merge pull request #1125 from MCTian-mi/recycling
Browse files Browse the repository at this point in the history
Actually fixes the RecyclingHelper
  • Loading branch information
bruberu authored Nov 27, 2024
2 parents b28bea3 + 151cc57 commit 027c741
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions groovy/globals/RecyclingHelper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ class RecyclingHelper {

static final void handleRecycling(ItemStack output, List<?> inputs) {
RecyclingRecipes.registerRecyclingRecipes(output.withAmount(1),
getRecyclingIngredients(output.getAmount(), inputs.flatten()).getMaterials(),
false, /*OreDictUnifier.getPrefix(output)*/ null) // See the comment at the top of this class
getRecyclingIngredients(output.getAmount(), inputs.flatten()),
false, OreDictUnifier.getPrefix(output)) // See the comment at the top of this class
}

private static final ItemMaterialInfo getRecyclingIngredients(int outputCount, List<IIngredient> inputs) {
private static final List<MaterialStack> getRecyclingIngredients(int outputCount, List<IIngredient> inputs) {

Object2LongMap<Material> materialStacksExploded = new Object2LongOpenHashMap<>();

for (IIngredient input : inputs) {
if (input == null || input.isEmpty()) continue
addItemStackToMaterialStacks(input.getMatchingStacks()[0], materialStacksExploded, input.getAmount())
addItemStackToMaterialStacks(input.withAmount(1).getMatchingStacks()[0], materialStacksExploded, input.getAmount())
}

return new ItemMaterialInfo(materialStacksExploded.entrySet().stream()
return materialStacksExploded.entrySet().stream()
.map(e -> new MaterialStack(e.getKey(), e.getValue().intdiv(outputCount)))
.sorted(Comparator.comparingLong(m -> -m.amount))
.collect(Collectors.toList()));
.collect(Collectors.toList());
}

private static final void addItemStackToMaterialStacks(ItemStack itemStack, Object2LongMap<Material> materialStacksExploded, int inputCount) {
Expand Down

0 comments on commit 027c741

Please sign in to comment.