mirror of
https://github.com/PikaMug/Quests.git
synced 2025-03-10 05:39:20 +01:00
Address shift-clicking smaller crafting results, fixes #1235
This commit is contained in:
parent
6e761857bc
commit
869dfc16c0
@ -62,13 +62,12 @@ public class ItemListener implements Listener {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private ItemStack getCraftedItem(CraftItemEvent evt) {
|
private ItemStack getCraftedItem(CraftItemEvent evt) {
|
||||||
if (evt.isShiftClick()) {
|
if (evt.isShiftClick()) {
|
||||||
ItemStack recipeResult = evt.getRecipe().getResult();
|
final ItemStack recipeResult = evt.getRecipe().getResult();
|
||||||
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 (ItemStack item : evt.getInventory().getMatrix()) {
|
for (ItemStack item : evt.getInventory().getMatrix()) {
|
||||||
if (item != null && !item.getType().equals(Material.AIR)) {
|
if (item != null && !item.getType().equals(Material.AIR)) {
|
||||||
leastIngredient = Math.min(leastIngredient * resultAmt, item.getAmount() * resultAmt);
|
leastIngredient = item.getAmount() * resultAmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability());
|
return new ItemStack(recipeResult.getType(), leastIngredient, recipeResult.getDurability());
|
||||||
|
Loading…
Reference in New Issue
Block a user