mirror of
https://github.com/PikaMug/Quests.git
synced 2025-01-20 23:31:36 +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();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class PlayerListener implements Listener {
|
||||
} catch (NoSuchMethodError err) {
|
||||
// Do nothing, getHand() not present pre-1.9
|
||||
}
|
||||
if (e == null || e.equals(EquipmentSlot.HAND)) { //If the event is fired by HAND (main hand)
|
||||
if (e == null || e.equals(EquipmentSlot.HAND)) { // If the event is fired by HAND (main hand)
|
||||
if (evt.hasBlock() && ItemUtil.isJournal(evt.getPlayer().getItemInHand())) {
|
||||
if (evt.getClickedBlock().getType().name().contains("PORTAL")
|
||||
&& plugin.getSettings().canAllowPranks()) {
|
||||
|
Loading…
Reference in New Issue
Block a user