Merge pull request #352 from ItsAlxl/NegativeAlc

Allow brew recipes to reduce alcohol level
This commit is contained in:
Sn0wStorm
2021-04-06 17:32:49 +02:00
committed by GitHub
11 changed files with 34 additions and 26 deletions
+1
View File
@@ -442,6 +442,7 @@ recipes:
cookingtime: 2 cookingtime: 2
color: BLACK color: BLACK
difficulty: 3 difficulty: 3
alcohol: -6
lore: + &8Probably a week old lore: + &8Probably a week old
effects: effects:
- REGENERATION/1/2-5 - REGENERATION/1/2-5
+1
View File
@@ -821,6 +821,7 @@ recipes:
# cookingtime: 1 # cookingtime: 1
# color: BLACK # color: BLACK
# difficulty: 4 # difficulty: 4
# alcohol: -8
# effects: # effects:
# - REGENERATION/30 # - REGENERATION/30
# - SPEED/10 # - SPEED/10
+2
View File
@@ -739,6 +739,7 @@ recipes:
cookingtime: 2 cookingtime: 2
color: BLACK color: BLACK
difficulty: 3 difficulty: 3
alcohol: -6
lore: + &8Probably a week old lore: + &8Probably a week old
effects: effects:
- REGENERATION/1/2-5 - REGENERATION/1/2-5
@@ -816,6 +817,7 @@ recipes:
# cookingtime: 1 # cookingtime: 1
# color: BLACK # color: BLACK
# difficulty: 4 # difficulty: 4
# alcohol: -8
# effects: # effects:
# - REGENERATION/30 # - REGENERATION/30
# - SPEED/10 # - SPEED/10
+2
View File
@@ -739,6 +739,7 @@ recipes:
cookingtime: 2 cookingtime: 2
color: BLACK color: BLACK
difficulty: 3 difficulty: 3
alcohol: -6
lore: + &8Probablemente una semana de edad lore: + &8Probablemente una semana de edad
effects: effects:
- REGENERATION/1/2-5 - REGENERATION/1/2-5
@@ -816,6 +817,7 @@ recipes:
# cookingtime: 1 # cookingtime: 1
# color: BLACK # color: BLACK
# difficulty: 4 # difficulty: 4
# alcohol: -8
# effects: # effects:
# - REGENERATION/30 # - REGENERATION/30
# - SPEED/10 # - SPEED/10
+2
View File
@@ -746,6 +746,7 @@ recipes:
cookingtime: 2 cookingtime: 2
color: BLACK color: BLACK
difficulty: 3 difficulty: 3
alcohol: -6
lore: + &8Probably a week old lore: + &8Probably a week old
effects: effects:
- REGENERATION/1/2-5 - REGENERATION/1/2-5
@@ -822,6 +823,7 @@ recipes:
# cookingtime: 1 # cookingtime: 1
# color: BLACK # color: BLACK
# difficulty: 4 # difficulty: 4
# alcohol: -8
# effects: # effects:
# - REGENERATION/30 # - REGENERATION/30
# - SPEED/10 # - SPEED/10
+1
View File
@@ -816,6 +816,7 @@ eggnog:
# cookingtime: 1 # cookingtime: 1
# color: BLACK # color: BLACK
# difficulty: 4 # difficulty: 4
# alcohol: -8
# effects: # effects:
# - REGENERATION/30 # - REGENERATION/30
# - SPEED/10 # - SPEED/10
+1
View File
@@ -820,6 +820,7 @@ recipes:
# cookingtime: 1 # cookingtime: 1
# color: BLACK # color: BLACK
# difficulty: 4 # difficulty: 4
# alcohol: -6
# effects: # effects:
# - REGENERATION/30 # - REGENERATION/30
# - SPEED/10 # - SPEED/10
+10 -9
View File
@@ -180,31 +180,32 @@ public class BPlayer {
int quality = drinkEvent.getQuality(); int quality = drinkEvent.getQuality();
List<PotionEffect> effects = getBrewEffects(brew.getEffects(), quality); List<PotionEffect> effects = getBrewEffects(brew.getEffects(), quality);
if (brewAlc < 1) {
//no alcohol so we dont need to add a BPlayer
applyEffects(effects, player, PlayerEffectEvent.EffectType.DRINK); applyEffects(effects, player, PlayerEffectEvent.EffectType.DRINK);
if (bPlayer.drunkeness <= 0) { if (brewAlc < 0) {
bPlayer.remove(); bPlayer.drain(player, -brewAlc);
} } else if (brewAlc > 0) {
return true;
}
bPlayer.drunkeness += brewAlc; bPlayer.drunkeness += brewAlc;
if (quality > 0) { if (quality > 0) {
bPlayer.quality += quality * brewAlc; bPlayer.quality += quality * brewAlc;
} else { } else {
bPlayer.quality += brewAlc; bPlayer.quality += brewAlc;
} }
applyEffects(effects, player, PlayerEffectEvent.EffectType.DRINK);
applyEffects(getQualityEffects(quality, brewAlc), player, PlayerEffectEvent.EffectType.QUALITY); applyEffects(getQualityEffects(quality, brewAlc), player, PlayerEffectEvent.EffectType.QUALITY);
}
if (bPlayer.drunkeness > 100) { if (bPlayer.drunkeness > 100) {
bPlayer.drinkCap(player); bPlayer.drinkCap(player);
} }
bPlayer.syncToSQL(false); bPlayer.syncToSQL(false);
if (BConfig.showStatusOnDrink) { if (BConfig.showStatusOnDrink) {
bPlayer.showDrunkeness(player); bPlayer.showDrunkeness(player);
} }
if (bPlayer.drunkeness <= 0) {
bPlayer.remove();
}
return true; return true;
} }
+4 -3
View File
@@ -373,10 +373,8 @@ public class Brew implements Cloneable {
// quality decides 10% - 100% // quality decides 10% - 100%
alc *= ((float) quality / 10.0f); alc *= ((float) quality / 10.0f);
} }
if (alc > 0) {
return alc; return alc;
} }
}
return 0; return 0;
} }
@@ -516,7 +514,10 @@ public class Brew implements Cloneable {
} }
public int getOrCalcAlc() { public int getOrCalcAlc() {
return alc > 0 ? alc : (alc = calcAlcohol()); if (alc == 0) {
alc = calcAlcohol();
}
return alc;
} }
public void setAlc(int alc) { public void setAlc(int alc) {
+1 -1
View File
@@ -275,7 +275,7 @@ public class BrewLore {
} }
public void updateAlc(boolean inDistiller) { public void updateAlc(boolean inDistiller) {
if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc) && (!brew.hasRecipe() || brew.getCurrentRecipe().getAlcohol() > 0)) { if (!brew.isUnlabeled() && (inDistiller || BConfig.alwaysShowAlc) && (!brew.hasRecipe() || brew.getCurrentRecipe().getAlcohol() != 0)) {
int alc = brew.getOrCalcAlc(); int alc = brew.getOrCalcAlc();
addOrReplaceLore(Type.ALC, "§8", P.p.languageReader.get("Brew_Alc", alc + "")); addOrReplaceLore(Type.ALC, "§8", P.p.languageReader.get("Brew_Alc", alc + ""));
} else { } else {
-4
View File
@@ -338,10 +338,6 @@ public class BRecipe {
P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName()); P.p.errorLog("Invalid difficulty '" + difficulty + "' in Recipe: " + getRecipeName());
return false; return false;
} }
if (alcohol < 0) {
P.p.errorLog("Invalid alcohol '" + alcohol + "' in Recipe: " + getRecipeName());
return false;
}
return true; return true;
} }