Fix part builder leftover dupe
Happens with recipes that are an exact multiple of the input material size, and with recipes that cost more than the input material size for inputs with leftovers
@@ -57,8 +57,11 @@ public interface IPartBuilderRecipe extends ICommonRecipe<IPartBuilderContainer>
if (recipe != null) {
int value = recipe.getValue();
if (value > 1) {
- int remainder = value - getCost() % value;
- if (remainder > 0) {
+ int remainder = (value - getCost()) % value;
+ if (remainder < 0) {
+ remainder += value;
+ }
+ if (remainder != 0) {
ItemStack leftover = recipe.getLeftover();
leftover.setCount(leftover.getCount() * remainder);
return leftover;
