mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-24 17:47:44 +01:00
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
This commit is contained in:
parent
4f1f10333f
commit
4aeda6e9e8
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user