mirror of
https://github.com/PikaMug/Quests.git
synced 2025-02-01 13:11:33 +01:00
Fix shift-click crafting recipe with result greater than 1, fixes #1235
This commit is contained in:
parent
f13e07f89b
commit
6e761857bc
@ -62,21 +62,16 @@ public class ItemListener implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
private ItemStack getCraftedItem(CraftItemEvent evt) {
|
||||
if (evt.isShiftClick()) {
|
||||
ItemStack result = evt.getRecipe().getResult();
|
||||
int numberOfItems = result.getAmount();
|
||||
int itemsChecked = 0;
|
||||
ItemStack recipeResult = evt.getRecipe().getResult();
|
||||
int resultAmt = recipeResult.getAmount(); // Bread = 1, Cookie = 8, etc.
|
||||
|
||||
int leastIngredient = 1;
|
||||
for (ItemStack item : evt.getInventory().getMatrix()) {
|
||||
if (item != null && !item.getType().equals(Material.AIR)) {
|
||||
if (itemsChecked == 0) {
|
||||
numberOfItems = item.getAmount();
|
||||
} else {
|
||||
numberOfItems = Math.min(numberOfItems, item.getAmount());
|
||||
itemsChecked++;
|
||||
leastIngredient = Math.min(leastIngredient * resultAmt, item.getAmount() * resultAmt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ItemStack(result.getType(), numberOfItems, result.getDurability());
|
||||
return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability());
|
||||
}
|
||||
return evt.getCurrentItem();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user