mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Merge pull request #2824 from DorCoMaNdO/master
Custom potion brewing now consume fuel from the brewing stand.
This commit is contained in:
commit
6a7279ea05
@ -26,7 +26,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Location location = brewingStand.getLocation();
|
Location location = brewingStand.getLocation();
|
||||||
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
|
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 (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) {
|
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {
|
||||||
|
@ -27,6 +27,7 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
private double brewSpeed;
|
private double brewSpeed;
|
||||||
private double brewTimer;
|
private double brewTimer;
|
||||||
private Player player;
|
private Player player;
|
||||||
|
private int fuel;
|
||||||
|
|
||||||
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
public AlchemyBrewTask(BlockState brewingStand, Player player) {
|
||||||
this.brewingStand = brewingStand;
|
this.brewingStand = brewingStand;
|
||||||
@ -51,13 +52,15 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
Alchemy.brewingStandMap.get(location).cancel();
|
Alchemy.brewingStandMap.get(location).cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fuel = ((BrewingStand) brewingStand).getFuelLevel() - 1;
|
||||||
|
|
||||||
Alchemy.brewingStandMap.put(location, this);
|
Alchemy.brewingStandMap.put(location, this);
|
||||||
this.runTaskTimer(mcMMO.p, 1, 1);
|
this.runTaskTimer(mcMMO.p, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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)) {
|
if (Alchemy.brewingStandMap.containsKey(location)) {
|
||||||
Alchemy.brewingStandMap.remove(location);
|
Alchemy.brewingStandMap.remove(location);
|
||||||
}
|
}
|
||||||
@ -67,6 +70,8 @@ public class AlchemyBrewTask extends BukkitRunnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((BrewingStand) brewingStand).setFuelLevel(fuel);
|
||||||
|
|
||||||
brewTimer -= brewSpeed;
|
brewTimer -= brewSpeed;
|
||||||
|
|
||||||
// Vanilla potion brewing completes when BrewingTime == 1
|
// Vanilla potion brewing completes when BrewingTime == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user