mirror of
https://github.com/DieReicheErethons/Brewery.git
synced 2024-06-28 10:44:48 +02:00
Added recipe option to set Distill Time
This commit is contained in:
parent
bd6742a599
commit
49efceaaae
|
@ -79,6 +79,7 @@ version: '1.5'
|
||||||
# Vault erkennt Namen wie "Jungle Leaves" anstatt "LEAVES,3". Dies macht es viel einfacher!
|
# Vault erkennt Namen wie "Jungle Leaves" anstatt "LEAVES,3". Dies macht es viel einfacher!
|
||||||
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
|
# cookingtime: Zeit in Echtminuten die die Zutaten kochen müssen
|
||||||
# distillruns: Wie oft destilliert werden muss für vollen Alkoholgehalt (0=ohne Destillieren)
|
# 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
|
# 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
|
# age: Zeit in Minecraft-Tagen, die das Getränk im Fass reifen muss 0= kein reifen
|
||||||
# color: Farbe des Getränks nach destillieren/reifen.
|
# color: Farbe des Getränks nach destillieren/reifen.
|
||||||
|
@ -107,6 +108,7 @@ recipes:
|
||||||
# - Green Dye/6 # Nur mit Vault
|
# - Green Dye/6 # Nur mit Vault
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 60
|
||||||
wood: 4
|
wood: 4
|
||||||
age: 11
|
age: 11
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -181,6 +183,7 @@ recipes:
|
||||||
- SUGAR_CANE/14
|
- SUGAR_CANE/14
|
||||||
cookingtime: 5
|
cookingtime: 5
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 30
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 14
|
age: 14
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -208,6 +211,7 @@ recipes:
|
||||||
- LONG_GRASS/15
|
- LONG_GRASS/15
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 6
|
distillruns: 6
|
||||||
|
distilltime: 80
|
||||||
color: GREEN
|
color: GREEN
|
||||||
difficulty: 8
|
difficulty: 8
|
||||||
alcohol: 45
|
alcohol: 45
|
||||||
|
|
|
@ -76,6 +76,7 @@ version: '1.5'
|
||||||
# Vault will recognize things like "Jungle Leaves" instead of "LEAVES,3"
|
# Vault will recognize things like "Jungle Leaves" instead of "LEAVES,3"
|
||||||
# cookingtime: Time in real minutes ingredients have to boil
|
# cookingtime: Time in real minutes ingredients have to boil
|
||||||
# distillruns: How often it has to be distilled for full alcohol (0=without distilling)
|
# 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
|
# 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
|
# age: Time in Minecraft-days, the potion has to age in a barrel 0=no aging
|
||||||
# color: Color of the potion after distilling/aging.
|
# color: Color of the potion after distilling/aging.
|
||||||
|
@ -104,6 +105,7 @@ recipes:
|
||||||
# - Green Dye/6 # Only with Vault
|
# - Green Dye/6 # Only with Vault
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 60
|
||||||
wood: 4
|
wood: 4
|
||||||
age: 11
|
age: 11
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -178,6 +180,7 @@ recipes:
|
||||||
- SUGAR_CANE/14
|
- SUGAR_CANE/14
|
||||||
cookingtime: 5
|
cookingtime: 5
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 30
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 14
|
age: 14
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -205,6 +208,7 @@ recipes:
|
||||||
- LONG_GRASS/15
|
- LONG_GRASS/15
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 6
|
distillruns: 6
|
||||||
|
distilltime: 80
|
||||||
color: GREEN
|
color: GREEN
|
||||||
difficulty: 8
|
difficulty: 8
|
||||||
alcohol: 45
|
alcohol: 45
|
||||||
|
|
|
@ -77,6 +77,7 @@ version: '1.5'
|
||||||
# Vault will recognize things like "Jungle Leaves" instead of "5,3"
|
# Vault will recognize things like "Jungle Leaves" instead of "5,3"
|
||||||
# cookingtime: Temps en minutes réelles durant lesquelles les ingrédients devront bouillir
|
# 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)
|
# 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
|
# 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
|
# 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.
|
# color: Couleur de la potion après distillation/avoir laissé vieillir.
|
||||||
|
@ -109,6 +110,7 @@ recipes:
|
||||||
# - Green Dye/6 # Only with Vault
|
# - Green Dye/6 # Only with Vault
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 60
|
||||||
wood: 4
|
wood: 4
|
||||||
age: 11
|
age: 11
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -183,6 +185,7 @@ recipes:
|
||||||
- SUGAR_CANE/14
|
- SUGAR_CANE/14
|
||||||
cookingtime: 5
|
cookingtime: 5
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 30
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 14
|
age: 14
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -210,6 +213,7 @@ recipes:
|
||||||
- LONG_GRASS/15
|
- LONG_GRASS/15
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 6
|
distillruns: 6
|
||||||
|
distilltime: 80
|
||||||
color: GREEN
|
color: GREEN
|
||||||
difficulty: 8
|
difficulty: 8
|
||||||
alcohol: 45
|
alcohol: 45
|
||||||
|
|
|
@ -76,6 +76,7 @@ version: '1.5'
|
||||||
# Vault riconoscerà cose come "Jungle Leaves" invece di "LEAVES,3".
|
# Vault riconoscerà cose come "Jungle Leaves" invece di "LEAVES,3".
|
||||||
# cookingtime: Tempo in minuti richiesto dagli ingredienti per bollire
|
# 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).
|
# 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
|
# 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).
|
# 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
|
# color: Colore della pozione dopo essere stata distillata/invecchiata
|
||||||
|
@ -104,6 +105,7 @@ recipes:
|
||||||
# - Green Dye/6 # Solo con Vault
|
# - Green Dye/6 # Solo con Vault
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 60
|
||||||
wood: 4
|
wood: 4
|
||||||
age: 11
|
age: 11
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -178,6 +180,7 @@ recipes:
|
||||||
- SUGAR_CANE/14
|
- SUGAR_CANE/14
|
||||||
cookingtime: 5
|
cookingtime: 5
|
||||||
distillruns: 2
|
distillruns: 2
|
||||||
|
distilltime: 30
|
||||||
wood: 2
|
wood: 2
|
||||||
age: 14
|
age: 14
|
||||||
color: DARK_RED
|
color: DARK_RED
|
||||||
|
@ -205,6 +208,7 @@ recipes:
|
||||||
- LONG_GRASS/15
|
- LONG_GRASS/15
|
||||||
cookingtime: 3
|
cookingtime: 3
|
||||||
distillruns: 6
|
distillruns: 6
|
||||||
|
distilltime: 80
|
||||||
color: GREEN
|
color: GREEN
|
||||||
difficulty: 8
|
difficulty: 8
|
||||||
alcohol: 45
|
alcohol: 45
|
||||||
|
|
|
@ -12,14 +12,15 @@ import java.util.List;
|
||||||
public class BRecipe {
|
public class BRecipe {
|
||||||
|
|
||||||
private String[] name;
|
private String[] name;
|
||||||
private ArrayList<ItemStack> ingredients = new ArrayList<>();// material and amount
|
private ArrayList<ItemStack> ingredients = new ArrayList<>(); // material and amount
|
||||||
private int cookingTime;// time to cook in cauldron
|
private int cookingTime; // time to cook in cauldron
|
||||||
private int distillruns;// runs through the brewer
|
private int distillruns; // runs through the brewer
|
||||||
private byte wood;// type of wood the barrel has to consist of
|
private int distillTime; // time for one distill run in seconds
|
||||||
private int age;// time in minecraft days for the potions to age in barrels
|
private byte wood; // type of wood the barrel has to consist of
|
||||||
private String color;// color of the destilled/finished potion
|
private int age; // time in minecraft days for the potions to age in barrels
|
||||||
private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
|
private String color; // color of the destilled/finished potion
|
||||||
private int alcohol;// Alcohol in perfect 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
|
private ArrayList<BEffect> effects = new ArrayList<>(); // Special Effects when drinking
|
||||||
|
|
||||||
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
|
||||||
|
@ -88,13 +89,14 @@ public class BRecipe {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime");
|
this.cookingTime = configSectionRecipes.getInt(recipeId + ".cookingtime", 1);
|
||||||
this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns");
|
this.distillruns = configSectionRecipes.getInt(recipeId + ".distillruns", 0);
|
||||||
this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood");
|
this.distillTime = configSectionRecipes.getInt(recipeId + ".distilltime", 0) * 20;
|
||||||
this.age = configSectionRecipes.getInt(recipeId + ".age");
|
this.wood = (byte) configSectionRecipes.getInt(recipeId + ".wood", 0);
|
||||||
|
this.age = configSectionRecipes.getInt(recipeId + ".age", 0);
|
||||||
this.color = configSectionRecipes.getString(recipeId + ".color");
|
this.color = configSectionRecipes.getString(recipeId + ".color");
|
||||||
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty");
|
this.difficulty = configSectionRecipes.getInt(recipeId + ".difficulty", 0);
|
||||||
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol");
|
this.alcohol = configSectionRecipes.getInt(recipeId + ".alcohol", 0);
|
||||||
|
|
||||||
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
|
List<String> effectStringList = configSectionRecipes.getStringList(recipeId + ".effects");
|
||||||
if (effectStringList != null) {
|
if (effectStringList != null) {
|
||||||
|
@ -131,6 +133,10 @@ public class BRecipe {
|
||||||
P.p.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getName(5));
|
P.p.errorLog("Invalid distillruns '" + distillruns + "' in Recipe: " + getName(5));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (distillTime < 0) {
|
||||||
|
P.p.errorLog("Invalid distilltime '" + distillTime + "' in Recipe: " + getName(5));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (wood < 0 || wood > 6) {
|
if (wood < 0 || wood > 6) {
|
||||||
P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getName(5));
|
P.p.errorLog("Invalid wood type '" + wood + "' in Recipe: " + getName(5));
|
||||||
return false;
|
return false;
|
||||||
|
@ -316,6 +322,10 @@ public class BRecipe {
|
||||||
return distillruns;
|
return distillruns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDistillTime() {
|
||||||
|
return distillTime;
|
||||||
|
}
|
||||||
|
|
||||||
public String getColor() {
|
public String getColor() {
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
return color.toUpperCase();
|
return color.toUpperCase();
|
||||||
|
|
|
@ -329,16 +329,13 @@ public class Brew {
|
||||||
// Distilling section ---------------
|
// Distilling section ---------------
|
||||||
|
|
||||||
// distill all custom potions in the brewer
|
// distill all custom potions in the brewer
|
||||||
public static void distillAll(BrewerInventory inv, Boolean[] contents) {
|
public static void distillAll(BrewerInventory inv, Brew[] contents) {
|
||||||
int slot = 0;
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
while (slot < 3) {
|
if (contents[slot] != null) {
|
||||||
if (contents[slot]) {
|
|
||||||
ItemStack slotItem = inv.getItem(slot);
|
ItemStack slotItem = inv.getItem(slot);
|
||||||
PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
|
PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
|
||||||
Brew brew = get(potionMeta);
|
contents[slot].distillSlot(slotItem, potionMeta);
|
||||||
brew.distillSlot(slotItem, potionMeta);
|
|
||||||
}
|
}
|
||||||
slot++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,6 +379,22 @@ public class Brew {
|
||||||
slotItem.setItemMeta(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 ------------------
|
// Ageing Section ------------------
|
||||||
|
|
||||||
public void age(ItemStack item, float time, byte woodType) {
|
public void age(ItemStack item, float time, byte woodType) {
|
||||||
|
|
|
@ -950,6 +950,35 @@ public class ConfigUpdater {
|
||||||
addLines(index, lines);
|
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
|
// Update de from 1.4 to 1.5
|
||||||
|
@ -993,6 +1022,35 @@ public class ConfigUpdater {
|
||||||
addLines(index, lines);
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class InventoryListener implements Listener {
|
||||||
/* === Recreating manually the prior BrewEvent behavior. === */
|
/* === Recreating manually the prior BrewEvent behavior. === */
|
||||||
private HashSet<UUID> trackedBrewmen = new HashSet<>();
|
private HashSet<UUID> trackedBrewmen = new HashSet<>();
|
||||||
private HashMap<Block, Integer> trackedBrewers = new HashMap<>();
|
private HashMap<Block, Integer> trackedBrewers = new HashMap<>();
|
||||||
private static final int DISTILLTIME = 401;
|
private static final int DISTILLTIME = 400;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start tracking distillation for a person when they open the brewer window.
|
* Start tracking distillation for a person when they open the brewer window.
|
||||||
|
@ -69,6 +69,15 @@ public class InventoryListener implements Listener {
|
||||||
trackedBrewmen.remove(player.getUniqueId());
|
trackedBrewmen.remove(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onBrewerDrag(InventoryDragEvent event) {
|
||||||
|
if (!P.use1_9) return;
|
||||||
|
// Workaround the Drag event when only clicking a slot
|
||||||
|
if (event.getInventory() instanceof BrewerInventory) {
|
||||||
|
onBrewerClick(new InventoryClickEvent(event.getView(), InventoryType.SlotType.CONTAINER, 0, ClickType.LEFT, InventoryAction.PLACE_ALL));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clicking can either start or stop the new brew distillation tracking.
|
* Clicking can either start or stop the new brew distillation tracking.
|
||||||
* Note that server restart will halt any ongoing brewing processes and
|
* Note that server restart will halt any ongoing brewing processes and
|
||||||
|
@ -102,13 +111,14 @@ public class InventoryListener implements Listener {
|
||||||
|
|
||||||
// Now check if we should bother to track it.
|
// Now check if we should bother to track it.
|
||||||
trackedBrewers.put(brewery, new BukkitRunnable() {
|
trackedBrewers.put(brewery, new BukkitRunnable() {
|
||||||
private int brewTime = DISTILLTIME;
|
private int runTime = -1;
|
||||||
|
private int brewTime = -1;
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
BlockState now = brewery.getState();
|
BlockState now = brewery.getState();
|
||||||
if (now instanceof BrewingStand) {
|
if (now instanceof BrewingStand) {
|
||||||
BrewingStand stand = (BrewingStand) now;
|
BrewingStand stand = (BrewingStand) now;
|
||||||
if (brewTime == DISTILLTIME) { // only check at the beginning (and end) for distillables
|
if (brewTime == -1) { // only check at the beginning (and end) for distillables
|
||||||
switch (hasCustom(stand.getInventory())) {
|
switch (hasCustom(stand.getInventory())) {
|
||||||
case 1:
|
case 1:
|
||||||
// Custom potion but not for distilling. Stop any brewing and cancel this task
|
// Custom potion but not for distilling. Stop any brewing and cancel this task
|
||||||
|
@ -126,12 +136,15 @@ public class InventoryListener implements Listener {
|
||||||
P.p.debugLog("nothing to distill");
|
P.p.debugLog("nothing to distill");
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
runTime = getLongestDistillTime(stand.getInventory());
|
||||||
|
brewTime = runTime;
|
||||||
|
P.p.log("using brewtime: " + runTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
brewTime--; // count down.
|
brewTime--; // count down.
|
||||||
stand.setBrewingTime(brewTime); // arbitrary for now
|
stand.setBrewingTime((int) ((float) brewTime / ((float) runTime / (float) DISTILLTIME)) + 1);
|
||||||
|
|
||||||
if (brewTime <= 1) { // Done!
|
if (brewTime <= 1) { // Done!
|
||||||
BrewerInventory brewer = stand.getInventory();
|
BrewerInventory brewer = stand.getInventory();
|
||||||
|
@ -141,7 +154,8 @@ public class InventoryListener implements Listener {
|
||||||
stand.setBrewingTime(0);
|
stand.setBrewingTime(0);
|
||||||
P.p.debugLog("All done distilling");
|
P.p.debugLog("All done distilling");
|
||||||
} else {
|
} else {
|
||||||
brewTime = DISTILLTIME; // go again.
|
brewTime = -1; // go again.
|
||||||
|
stand.setBrewingTime(0);
|
||||||
P.p.debugLog("Can distill more! Continuing.");
|
P.p.debugLog("Can distill more! Continuing.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,35 +168,39 @@ public class InventoryListener implements Listener {
|
||||||
}.runTaskTimer(P.p, 2L, 1L).getTaskId());
|
}.runTaskTimer(P.p, 2L, 1L).getTaskId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a Brew or null for every Slot in the BrewerInventory
|
||||||
|
private Brew[] getDistillContents(BrewerInventory inv) {
|
||||||
|
ItemStack item;
|
||||||
|
Brew[] contents = new Brew[3];
|
||||||
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
|
item = inv.getItem(slot);
|
||||||
|
if (item != null) {
|
||||||
|
contents[slot] = Brew.get(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
private byte hasCustom(BrewerInventory brewer) {
|
private byte hasCustom(BrewerInventory brewer) {
|
||||||
ItemStack item = brewer.getItem(3); // ingredient
|
ItemStack item = brewer.getItem(3); // ingredient
|
||||||
boolean glowstone = (item != null && Material.GLOWSTONE_DUST == item.getType()); // need dust in the top slot.
|
boolean glowstone = (item != null && Material.GLOWSTONE_DUST == item.getType()); // need dust in the top slot.
|
||||||
byte customFound = 0;
|
byte customFound = 0;
|
||||||
for (int slot = 0; slot < 3; slot++) {
|
for (Brew brew : getDistillContents(brewer)) {
|
||||||
item = brewer.getItem(slot);
|
if (brew != null) {
|
||||||
if (item != null) {
|
if (!glowstone) {
|
||||||
if (item.getType() == Material.POTION) {
|
return 1;
|
||||||
if (item.hasItemMeta()) {
|
}
|
||||||
int uid = Brew.getUID(item);
|
if (brew.canDistill()) {
|
||||||
Brew pot = Brew.potions.get(uid);
|
return 2;
|
||||||
if (pot != null) {
|
} else {
|
||||||
if (!glowstone) {
|
customFound = 1;
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (pot.canDistill()) {
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
customFound = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return customFound;
|
return customFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onBrew(BrewEvent event) {
|
public void onBrew(BrewEvent event) {
|
||||||
if (P.use1_9) {
|
if (P.use1_9) {
|
||||||
if (hasCustom(event.getContents()) != 0) {
|
if (hasCustom(event.getContents()) != 0) {
|
||||||
|
@ -196,29 +214,16 @@ public class InventoryListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean runDistill(BrewerInventory inv) {
|
private boolean runDistill(BrewerInventory inv) {
|
||||||
int slot = 0;
|
|
||||||
ItemStack item;
|
|
||||||
boolean custom = false;
|
boolean custom = false;
|
||||||
Boolean[] contents = new Boolean[3];
|
Brew[] contents = getDistillContents(inv);
|
||||||
while (slot < 3) {
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
item = inv.getItem(slot);
|
if (contents[slot] == null) continue;
|
||||||
contents[slot] = false;
|
if (contents[slot].canDistill()) {
|
||||||
if (item != null) {
|
// is further distillable
|
||||||
if (item.getType() == Material.POTION) {
|
custom = true;
|
||||||
if (item.hasItemMeta()) {
|
} else {
|
||||||
int uid = Brew.getUID(item);
|
contents[slot] = null;
|
||||||
if (Brew.potions.containsKey(uid)) {
|
|
||||||
// has custom potion in "slot"
|
|
||||||
if (Brew.get(uid).canDistill()) {
|
|
||||||
// is further distillable
|
|
||||||
contents[slot] = true;
|
|
||||||
custom = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
slot++;
|
|
||||||
}
|
}
|
||||||
if (custom) {
|
if (custom) {
|
||||||
Brew.distillAll(inv, contents);
|
Brew.distillAll(inv, contents);
|
||||||
|
@ -227,6 +232,27 @@ public class InventoryListener implements Listener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getLongestDistillTime(BrewerInventory inv) {
|
||||||
|
int bestTime = 0;
|
||||||
|
int time = 0;
|
||||||
|
Brew[] contents = getDistillContents(inv);
|
||||||
|
for (int slot = 0; slot < 3; slot++) {
|
||||||
|
if (contents[slot] == null) continue;
|
||||||
|
time = contents[slot].getDistillTimeNextRun();
|
||||||
|
if (time == 0) {
|
||||||
|
// Undefined Potion needs 40 seconds
|
||||||
|
time = 800;
|
||||||
|
}
|
||||||
|
if (time > bestTime) {
|
||||||
|
bestTime = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bestTime > 0) {
|
||||||
|
return bestTime;
|
||||||
|
}
|
||||||
|
return 800;
|
||||||
|
}
|
||||||
|
|
||||||
// Clicked a Brew somewhere, do some updating
|
// Clicked a Brew somewhere, do some updating
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = false)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = false)
|
||||||
public void onInventoryClickLow(InventoryClickEvent event) {
|
public void onInventoryClickLow(InventoryClickEvent event) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user