Adjust crafting progression from shift-click, by Lokio27

This commit is contained in:
PikaMug 2021-04-01 23:39:05 -04:00
parent 92412a89ff
commit 60a1f5b119

View File

@ -75,10 +75,13 @@ public class ItemListener implements Listener {
if (evt.isShiftClick()) { if (evt.isShiftClick()) {
final ItemStack recipeResult = evt.getRecipe().getResult(); final ItemStack recipeResult = evt.getRecipe().getResult();
final int resultAmt = recipeResult.getAmount(); // Bread = 1, Cookie = 8, etc. final int resultAmt = recipeResult.getAmount(); // Bread = 1, Cookie = 8, etc.
int leastIngredient = 1; int leastIngredient = -1;
for (final ItemStack item : evt.getInventory().getMatrix()) { for (final ItemStack item : evt.getInventory().getMatrix()) {
if (item != null && !item.getType().equals(Material.AIR)) { if (item != null && !item.getType().equals(Material.AIR)) {
leastIngredient = item.getAmount() * resultAmt; final int re = item.getAmount() * resultAmt;
if (leastIngredient == -1 || re < leastIngredient) {
leastIngredient = re;
}
} }
} }
return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability()); return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability());