From 4aeda6e9e810f3c86f88976926d8055c00a53654 Mon Sep 17 00:00:00 2001 From: t00thpick1 Date: Wed, 18 Mar 2015 16:23:07 -0400 Subject: [PATCH] Still not fully on track with the original event, but as we want them to see the potions we create, we can't be fully correct. However, correcting the behavior to decrement the ingredient after the event shouldn't harm anything. Fixes #2486 --- .../skills/alchemy/AlchemyPotionBrewer.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index b0965734f..a149ded15 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -56,23 +56,29 @@ public final class AlchemyPotionBrewer { return item == null || item.getType() == Material.AIR || item.getAmount() == 0; } - private static boolean removeIngredient(BrewerInventory inventory, Player player) { + private static void removeIngredient(BrewerInventory inventory, Player player) { ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) { - return false; + return; } else if (ingredient.getAmount() <= 1) { inventory.setIngredient(null); - return true; + return; } else { ingredient.setAmount(ingredient.getAmount() - 1); inventory.setIngredient(ingredient); - return true; + return; } } + private static boolean hasIngredient(BrewerInventory inventory, Player player) { + ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); + + return !isEmpty(ingredient) && isValidIngredient(player, ingredient); + } + public static boolean isValidIngredient(Player player, ItemStack item) { if (isEmpty(item)) { return false; @@ -99,7 +105,7 @@ public final class AlchemyPotionBrewer { BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory(); ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone(); - if (!removeIngredient(inventory, player)) { + if (!hasIngredient(inventory, player)) { return; } @@ -129,6 +135,8 @@ public final class AlchemyPotionBrewer { return; } + removeIngredient(inventory, player); + for (AlchemyPotion input : inputList) { AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));