Skip to content

Commit

Permalink
fix BrewingStand inventory is updated immediately instead of after fi…
Browse files Browse the repository at this point in the history
…ring the event. Now the event can be canceled correct. (#4351)
  • Loading branch information
Wolf2323 committed Dec 10, 2020
1 parent c4072ee commit 0e09ac3
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -114,6 +114,7 @@ public static void finishBrewing(BlockState brewingStand, Player player, boolean
}

List<AlchemyPotion> inputList = new ArrayList<>();
ItemStack[] outputList = new ItemStack[3];

for (int i = 0; i < 3; i++) {
ItemStack item = inventory.getItem(i);
Expand All @@ -128,7 +129,7 @@ public static void finishBrewing(BlockState brewingStand, Player player, boolean
inputList.add(input);

if (output != null) {
inventory.setItem(i, output.toItemStack(item.getAmount()).clone());
outputList[i] = output.toItemStack(item.getAmount()).clone();
}
}

Expand All @@ -139,6 +140,12 @@ public static void finishBrewing(BlockState brewingStand, Player player, boolean
return;
}

for (int i = 0; i < 3; i++) {
if(outputList[i] != null) {
inventory.setItem(i, outputList[i]);
}
}

removeIngredient(inventory, player);

for (AlchemyPotion input : inputList) {
Expand Down

0 comments on commit 0e09ac3

Please sign in to comment.