Skip to content

Commit

Permalink
Added recipe option to set Distill Time
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn0wStorm committed Jun 28, 2016
1 parent bd6742a commit 49efcea
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 66 deletions.
4 changes: 4 additions & 0 deletions resources/config/de/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ version: '1.5'
# Vault erkennt Namen wie "Jungle Leaves" anstatt "LEAVES,3". Dies macht es viel einfacher!
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
# distillruns: Wie oft destilliert werden muss für vollen Alkoholgehalt (0=ohne Destillieren)
# distilltime: Wie lange (in sekunden) ein Destillations-Durchlauf braucht (0=Standard Zeit von 40 sek) MC Standard wäre 20 sek
# wood: Holz des Fasses 0=alle Holzsorten 1=Birke 2=Eiche 3=Jungel 4=Fichte 5=Akazie 6=Schwarzeiche
# age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen
# color: Farbe des Getränks nach destillieren/reifen.
Expand Down Expand Up @@ -107,6 +108,7 @@ recipes:
# - Green Dye/6 # Nur mit Vault
cookingtime: 3
distillruns: 2
distilltime: 60
wood: 4
age: 11
color: DARK_RED
Expand Down Expand Up @@ -181,6 +183,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
distilltime: 30
wood: 2
age: 14
color: DARK_RED
Expand Down Expand Up @@ -208,6 +211,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
Expand Down
4 changes: 4 additions & 0 deletions resources/config/en/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ version: '1.5'
# Vault will recognize things like "Jungle Leaves" instead of "LEAVES,3"
# cookingtime: Time in real minutes ingredients have to boil
# distillruns: How often it has to be distilled for full alcohol (0=without distilling)
# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec
# wood: Wood of the barrel 0=any 1=Birch 2=Oak 3=Jungle 4=Spruce 5=Acacia 6=Dark Oak
# age: Time in Minecraft-days, the potion has to age in a barrel 0=no aging
# color: Color of the potion after distilling/aging.
Expand Down Expand Up @@ -104,6 +105,7 @@ recipes:
# - Green Dye/6 # Only with Vault
cookingtime: 3
distillruns: 2
distilltime: 60
wood: 4
age: 11
color: DARK_RED
Expand Down Expand Up @@ -178,6 +180,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
distilltime: 30
wood: 2
age: 14
color: DARK_RED
Expand Down Expand Up @@ -205,6 +208,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
Expand Down
4 changes: 4 additions & 0 deletions resources/config/fr/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ version: '1.5'
# Vault will recognize things like "Jungle Leaves" instead of "5,3"
# cookingtime: Temps en minutes réelles durant lesquelles les ingrédients devront bouillir
# distillruns: Combien de fois le breuvage devra être distillé pour un alcool de qualité (0=Ne pas distiller)
# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec
# wood: Type de bois du baril 0=aucun 1=Bouleau 2=Chêne 3=Jungle 4=Pin 5=Acacia 6=Chêne Noir
# age: Temps en jours de Minecraft, la potion devra être âgée dans un baril. 0=Pas besoin d'âge
# color: Couleur de la potion après distillation/avoir laissé vieillir.
Expand Down Expand Up @@ -109,6 +110,7 @@ recipes:
# - Green Dye/6 # Only with Vault
cookingtime: 3
distillruns: 2
distilltime: 60
wood: 4
age: 11
color: DARK_RED
Expand Down Expand Up @@ -183,6 +185,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
distilltime: 30
wood: 2
age: 14
color: DARK_RED
Expand Down Expand Up @@ -210,6 +213,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
Expand Down
4 changes: 4 additions & 0 deletions resources/config/it/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ version: '1.5'
# Vault riconoscerà cose come "Jungle Leaves" invece di "LEAVES,3".
# cookingtime: Tempo in minuti richiesto dagli ingredienti per bollire
# distillruns: Quanto spesso deve essere distillato per ottenere la versione perfetta con il volume alcolico impostato (0=non serve distillare).
# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec
# wood: Legno del barile 0=qualiasi 1=Betulla 2=Quercia 3=Mogano 4=Abete 5=Acacia 6=Quercia nera
# age: Tempo in giorni di Minecraft per cui la pozione deve essere invecchiata in un barile (0=nessun invecchiamento).
# color: Colore della pozione dopo essere stata distillata/invecchiata
Expand Down Expand Up @@ -104,6 +105,7 @@ recipes:
# - Green Dye/6 # Solo con Vault
cookingtime: 3
distillruns: 2
distilltime: 60
wood: 4
age: 11
color: DARK_RED
Expand Down Expand Up @@ -178,6 +180,7 @@ recipes:
- SUGAR_CANE/14
cookingtime: 5
distillruns: 2
distilltime: 30
wood: 2
age: 14
color: DARK_RED
Expand Down Expand Up @@ -205,6 +208,7 @@ recipes:
- LONG_GRASS/15
cookingtime: 3
distillruns: 6
distilltime: 80
color: GREEN
difficulty: 8
alcohol: 45
Expand Down
38 changes: 24 additions & 14 deletions src/com/dre/brewery/BRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
public class BRecipe {

private String[] name;
private ArrayList<ItemStack> ingredients = new ArrayList<>();// material and amount
private int cookingTime;// time to cook in cauldron
private int distillruns;// runs through the brewer
private byte wood;// type of wood the barrel has to consist of
private int age;// time in minecraft days for the potions to age in barrels
private String color;// color of the destilled/finished potion
private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
private int alcohol;// Alcohol in perfect potion
private ArrayList<ItemStack> ingredients = new ArrayList<>(); // material and amount
private int cookingTime; // time to cook in cauldron
private int distillruns; // runs through the brewer
private int distillTime; // time for one distill run in seconds
private byte wood; // type of wood the barrel has to consist of
private int age; // time in minecraft days for the potions to age in barrels
private String color; // color of the destilled/finished potion
private int difficulty; // difficulty to brew the potion, how exact the instruction has to be followed
private int alcohol; // Alcohol in perfect potion
private ArrayList<BEffect> effects = new ArrayList<>(); // Special Effects when drinking

public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
Expand Down Expand Up @@ -88,13 +89,14 @@ public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
}
}
}
this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime");
this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns");
this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood");
this.age = configSectionRecipes.getInt(recipeId + ".age");
this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
this.distillTime = configSectionRecipes.getInt(recipeId + ".distilltime", 0) * 20;
this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood", 0);
this.age = configSectionRecipes.getInt(recipeId + ".age", 0);
this.color = configSectionRecipes.getString(recipeId + ".color");
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty", 0);
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol", 0);

List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
if (effectStringList != null) {
Expand Down Expand Up @@ -131,6 +133,10 @@ public boolean isValid() {
P.p.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getName(5));
return false;
}
if (distillTime < 0) {
P.p.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getName(5));
return false;
}
if (wood < 0 || wood > 6) {
P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getName(5));
return false;
Expand Down Expand Up @@ -316,6 +322,10 @@ public int getDistillRuns() {
return distillruns;
}

public int getDistillTime() {
return distillTime;
}

public String getColor() {
if (color != null) {
return color.toUpperCase();
Expand Down
27 changes: 20 additions & 7 deletions src/com/dre/brewery/Brew.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,13 @@ public int getLastUpdate() {
// Distilling section ---------------

// distill all custom potions in the brewer
public static void distillAll(BrewerInventory inv, Boolean[] contents) {
int slot = 0;
while (slot < 3) {
if (contents[slot]) {
public static void distillAll(BrewerInventory inv, Brew[] contents) {
for (int slot = 0; slot < 3; slot++) {
if (contents[slot] != null) {
ItemStack slotItem = inv.getItem(slot);
PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
Brew brew = get(potionMeta);
brew.distillSlot(slotItem, potionMeta);
contents[slot].distillSlot(slotItem, potionMeta);
}
slot++;
}
}

Expand Down Expand Up @@ -382,6 +379,22 @@ public void distillSlot(ItemStack slotItem, PotionMeta potionMeta) {
slotItem.setItemMeta(potionMeta);
}

public int getDistillTimeNextRun() {
if (!canDistill()) {
return -1;
}

if (currentRecipe != null) {
return currentRecipe.getDistillTime();
}

BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
if (recipe != null) {
return recipe.getDistillTime();
}
return 0;
}

// Ageing Section ------------------

public void age(ItemStack item, float time, byte woodType) {
Expand Down
58 changes: 58 additions & 0 deletions src/com/dre/brewery/filedata/ConfigUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,35 @@ private void update14de() {
addLines(index, lines);
}
}

lines = new String[] {"# distilltime: Wie lange (in sekunden) ein Destillations-Durchlauf braucht (0=Standard Zeit von 40 sek) MC Standard wäre 20 sek"};

index = indexOfStart("# distillruns:");
if (index == -1) {
index = indexOfStart("# wood:") - 1;
if (index == -2) {
index = indexOfStart("# -- Rezepte") + 1;
if (index == 0) {
index = -1;
}
}
}
if (index != -1) {
addLines(index + 1, lines);
}

index = indexOfStart(" name: Schlechtes Beispiel/Beispiel/Gutes Beispiel");
if (index != -1) {
addLines(index + 1, " distilltime: 60");
}
index = indexOfStart(" name: Bitterer Rum/Würziger Rum/&6Goldener Rum");
if (index != -1) {
addLines(index + 1, " distilltime: 30");
}
index = indexOfStart(" name: minderwertiger Absinth/Absinth/Starker Absinth");
if (index != -1) {
addLines(index + 1, " distilltime: 80");
}
}

// Update de from 1.4 to 1.5
Expand Down Expand Up @@ -993,6 +1022,35 @@ private void update14en() {
addLines(index, lines);
}
}

lines = new String[] {"# distilltime: How long (in seconds) one distill-run takes (0=Default time of 40 sec) MC Default would be 20 sec"};

index = indexOfStart("# distillruns:");
if (index == -1) {
index = indexOfStart("# wood:") - 1;
if (index == -2) {
index = indexOfStart("# -- Recipes") + 1;
if (index == 0) {
index = -1;
}
}
}
if (index != -1) {
addLines(index + 1, lines);
}

index = indexOfStart(" name: Bad Example/Example/Good Example");
if (index != -1) {
addLines(index + 1, " distilltime: 60");
}
index = indexOfStart(" name: Bitter Rum/Spicy Rum/&6Golden Rum");
if (index != -1) {
addLines(index + 1, " distilltime: 30");
}
index = indexOfStart(" name: Poor Absinthe/Absinthe/Strong Absinthe");
if (index != -1) {
addLines(index + 1, " distilltime: 80");
}
}


Expand Down
Loading

0 comments on commit 49efcea

Please sign in to comment.