Fixes a bug in multi-item salvage
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
@ -72,12 +72,28 @@ public final class SalvageHelper {
|
||||
}
|
||||
|
||||
//Make sure to give salvage for all items if a stack > 1 is provided
|
||||
List<ItemStack> salvage = new ArrayList<>();
|
||||
List<ItemStack> allSalvage = new ArrayList<>();
|
||||
for (int i = 0; i < salvagedItem.getAmount(); i++) {
|
||||
salvage.addAll(getSalvage(ingredients, salvagedItem));
|
||||
allSalvage.addAll(getSalvage(copyItems(ingredients), salvagedItem));
|
||||
}
|
||||
|
||||
return combineStacks(salvage);
|
||||
return combineStacks(allSalvage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies a list of items
|
||||
*
|
||||
* <p>Note: This does not copy any metadata. It only copies the item type and the amount.</p>
|
||||
*
|
||||
* @param itemsToCopy <p>The items to make a copy of</p>
|
||||
* @return <p>A copy of the given items</p>
|
||||
*/
|
||||
private static List<ItemStack> copyItems(List<ItemStack> itemsToCopy) {
|
||||
List<ItemStack> copies = new ArrayList<>(itemsToCopy.size());
|
||||
for (ItemStack itemStack : itemsToCopy) {
|
||||
copies.add(new ItemStack(itemStack.getType(), itemStack.getAmount()));
|
||||
}
|
||||
return copies;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user