From 4054315c190ab11c2223919b23b4d65029498b32 Mon Sep 17 00:00:00 2001 From: Dor Date: Wed, 16 Mar 2016 15:16:48 +0200 Subject: [PATCH] Custom potion brewing now consume fuel from the brewing stand. Fixed a glitch that let players remove the ingredient of a custom potion from the brewing stand without cancelling the brewing task (this doesn't seem to have caused any duplicates, once the task finished nothing happened). --- .../nossr50/runnables/skills/AlchemyBrewCheckTask.java | 2 +- .../gmail/nossr50/runnables/skills/AlchemyBrewTask.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java index c1517ec64..5aabfe51e 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewCheckTask.java @@ -26,7 +26,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable { public void run() { Location location = brewingStand.getLocation(); ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4); - boolean validBrew = AlchemyPotionBrewer.isValidBrew(player, newInventory); + boolean validBrew = brewingStand.getFuelLevel() > 0 && AlchemyPotionBrewer.isValidBrew(player, newInventory); if (Alchemy.brewingStandMap.containsKey(location)) { if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) { diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java index cfcac3ca5..e046dee2f 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/AlchemyBrewTask.java @@ -27,6 +27,7 @@ public class AlchemyBrewTask extends BukkitRunnable { private double brewSpeed; private double brewTimer; private Player player; + private int fuel; public AlchemyBrewTask(BlockState brewingStand, Player player) { this.brewingStand = brewingStand; @@ -50,6 +51,8 @@ public class AlchemyBrewTask extends BukkitRunnable { if (Alchemy.brewingStandMap.containsKey(location)) { Alchemy.brewingStandMap.get(location).cancel(); } + + fuel = ((BrewingStand) brewingStand).getFuelLevel() - 1; Alchemy.brewingStandMap.put(location, this); this.runTaskTimer(mcMMO.p, 1, 1); @@ -57,7 +60,7 @@ public class AlchemyBrewTask extends BukkitRunnable { @Override public void run() { - if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) { + if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND || !AlchemyPotionBrewer.isValidIngredient(player, ((BrewingStand) brewingStand).getInventory().getContents()[Alchemy.INGREDIENT_SLOT])) { if (Alchemy.brewingStandMap.containsKey(location)) { Alchemy.brewingStandMap.remove(location); } @@ -66,6 +69,8 @@ public class AlchemyBrewTask extends BukkitRunnable { return; } + + ((BrewingStand) brewingStand).setFuelLevel(fuel); brewTimer -= brewSpeed;