Brewery/src/com/dre/brewery/Brew.java

677 lines
18 KiB
Java
Raw Normal View History

2013-04-28 23:57:41 +02:00
package com.dre.brewery;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
2013-05-28 16:25:06 +02:00
import java.util.List;
2013-04-28 23:57:41 +02:00
2014-05-19 15:17:55 +02:00
import org.bukkit.Material;
2013-04-30 21:41:16 +02:00
import org.bukkit.configuration.ConfigurationSection;
2013-04-28 23:57:41 +02:00
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.inventory.BrewerInventory;
public class Brew {
// represents the liquid in the brewed Potions
public static Map<Integer, Brew> potions = new HashMap<Integer, Brew>();
public static Boolean colorInBarrels; // color the Lore while in Barrels
public static Boolean colorInBrewer; // color the Lore while in Brewer
2013-04-28 23:57:41 +02:00
private BIngredients ingredients;
private int quality;
private int distillRuns;
private float ageTime;
2013-09-05 17:09:20 +02:00
private float wood;
2013-05-28 16:25:06 +02:00
private BRecipe currentRecipe;
2013-08-30 21:19:49 +02:00
private boolean unlabeled;
2014-06-03 23:10:47 +02:00
private boolean persistent;
2014-09-03 22:03:03 +02:00
private boolean stat; // static potions should not be changed
2013-04-28 23:57:41 +02:00
public Brew(int uid, BIngredients ingredients) {
2013-04-28 23:57:41 +02:00
this.ingredients = ingredients;
potions.put(uid, this);
2013-04-28 23:57:41 +02:00
}
// quality already set
2013-05-28 16:25:06 +02:00
public Brew(int uid, int quality, BRecipe recipe, BIngredients ingredients) {
2013-04-28 23:57:41 +02:00
this.ingredients = ingredients;
this.quality = quality;
2013-05-28 16:25:06 +02:00
this.currentRecipe = recipe;
potions.put(uid, this);
2013-04-28 23:57:41 +02:00
}
// loading from file
2014-09-03 22:03:03 +02:00
public Brew(int uid, BIngredients ingredients, int quality, int distillRuns, float ageTime, float wood, String recipe, boolean unlabeled, boolean persistent, boolean stat) {
potions.put(uid, this);
2013-04-30 21:41:16 +02:00
this.ingredients = ingredients;
this.quality = quality;
this.distillRuns = distillRuns;
this.ageTime = ageTime;
2013-09-05 17:09:20 +02:00
this.wood = wood;
2013-08-30 21:19:49 +02:00
this.unlabeled = unlabeled;
2014-06-03 23:10:47 +02:00
this.persistent = persistent;
2014-09-03 22:03:03 +02:00
this.stat = stat;
2013-09-05 18:46:33 +02:00
setRecipeFromString(recipe);
2013-04-30 21:41:16 +02:00
}
// returns a Brew by its UID
public static Brew get(int uid) {
if (uid < -1) {
if (!potions.containsKey(uid)) {
P.p.errorLog("Database failure! unable to find UID " + uid + " of a custom Potion!");
return null;// throw some exception?
2013-04-28 23:57:41 +02:00
}
} else {
return null;
}
return potions.get(uid);
}
// returns a Brew by PotionMeta
public static Brew get(PotionMeta meta) {
2013-05-01 21:47:41 +02:00
return get(getUID(meta));
2013-04-28 23:57:41 +02:00
}
// returns a Brew by ItemStack
2013-08-20 23:19:23 +02:00
public static Brew get(ItemStack item) {
2014-05-19 15:17:55 +02:00
if (item.getType() == Material.POTION) {
2013-08-20 23:19:23 +02:00
if (item.hasItemMeta()) {
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
return get(potionMeta);
}
}
return null;
}
2013-04-28 23:57:41 +02:00
// returns UID of custom Potion item
public static int getUID(ItemStack item) {
2013-05-01 21:47:41 +02:00
return getUID((PotionMeta) item.getItemMeta());
}
// returns UID of custom Potion meta
public static int getUID(PotionMeta potionMeta) {
if (potionMeta.hasCustomEffect(PotionEffectType.REGENERATION)) {
for (PotionEffect effect : potionMeta.getCustomEffects()) {
if (effect.getType().equals(PotionEffectType.REGENERATION)) {
if (effect.getDuration() < -1) {
2013-05-01 21:47:41 +02:00
return effect.getDuration();
}
}
}
}
return 0;
}
// generate an UID
public static int generateUID() {
2013-05-01 21:47:41 +02:00
int uid = -2;
while (potions.containsKey(uid)) {
2013-05-01 21:47:41 +02:00
uid -= 1;
}
return uid;
}
2013-09-05 18:46:33 +02:00
//returns the recipe with the given name, recalculates if not found
public boolean setRecipeFromString(String name) {
currentRecipe = null;
if (name != null && !name.equals("")) {
for (BRecipe recipe : BIngredients.recipes) {
if (recipe.getName(5).equalsIgnoreCase(name)) {
currentRecipe = recipe;
return true;
}
}
if (quality > 0) {
currentRecipe = ingredients.getBestRecipe(wood, ageTime, distillRuns > 0);
if (currentRecipe != null) {
2014-09-03 22:03:03 +02:00
if (!stat) {
this.quality = calcQuality();
}
2013-09-05 18:46:33 +02:00
P.p.log("Brew was made from Recipe: '" + name + "' which could not be found. '" + currentRecipe.getName(5) + "' used instead!");
return true;
} else {
P.p.errorLog("Brew was made from Recipe: '" + name + "' which could not be found!");
}
}
}
return false;
}
public boolean reloadRecipe() {
if (currentRecipe != null) {
return setRecipeFromString(currentRecipe.getName(5));
}
return true;
}
2013-08-20 23:19:23 +02:00
// Copy a Brew with a new unique ID and return its item
public ItemStack copy(ItemStack item) {
ItemStack copy = item.clone();
int uid = generateUID();
clone(uid);
PotionMeta meta = (PotionMeta) copy.getItemMeta();
meta.addCustomEffect((PotionEffectType.REGENERATION).createEffect((uid * 4), 0), true);
copy.setItemMeta(meta);
return copy;
}
// Clones this instance with a new unique ID
public Brew clone(int uid) {
Brew brew = new Brew(uid, quality, currentRecipe, ingredients);
brew.distillRuns = distillRuns;
brew.ageTime = ageTime;
2013-08-30 21:19:49 +02:00
brew.unlabeled = unlabeled;
2014-09-03 22:03:03 +02:00
if (!brew.persistent) {
brew.stat = stat;
}
2013-08-20 23:19:23 +02:00
return brew;
}
2014-06-03 23:10:47 +02:00
// remove potion from file (drinking, despawning, combusting, cmdDeleting, should be more!)
public void remove(ItemStack item) {
if (!persistent) {
potions.remove(getUID(item));
}
}
// calculate alcohol from recipe
2013-05-28 16:25:06 +02:00
public int calcAlcohol() {
2013-08-30 21:19:49 +02:00
if (quality == 0) {
// Give bad potions some alc
2013-08-31 18:23:03 +02:00
int badAlc = 0;
2013-08-30 21:19:49 +02:00
if (distillRuns > 1) {
2013-08-31 18:23:03 +02:00
badAlc = distillRuns;
}
if (ageTime > 10) {
badAlc += 5;
} else if (ageTime > 2) {
badAlc += 3;
}
if (currentRecipe != null) {
return badAlc;
2013-08-30 21:19:49 +02:00
} else {
2013-08-31 18:23:03 +02:00
return badAlc / 2;
2013-08-30 21:19:49 +02:00
}
}
2013-08-31 18:23:03 +02:00
2013-05-28 16:25:06 +02:00
if (currentRecipe != null) {
int alc = currentRecipe.getAlcohol();
2013-07-03 18:06:13 +02:00
if (currentRecipe.needsDistilling()) {
2013-08-30 21:19:49 +02:00
if (distillRuns == 0) {
return 0;
}
// bad quality can decrease alc by up to 40%
alc *= 1 - ((float) (10 - quality) * 0.04);
// distillable Potions should have half alc after one and full alc after all needed distills
alc /= 2;
alc *= 1.0F + ((float) distillRuns / currentRecipe.getDistillRuns()) ;
} else {
// quality decides 10% - 100%
alc *= ((float) quality / 10.0);
}
if (alc > 0) {
return alc;
2013-05-28 16:25:06 +02:00
}
2013-05-10 00:01:28 +02:00
}
2013-05-28 16:25:06 +02:00
return 0;
2013-04-30 01:23:29 +02:00
}
// calculating quality
2013-09-05 17:09:20 +02:00
public int calcQuality() {
// calculate quality from all of the factors
2013-09-05 17:09:20 +02:00
float quality = ingredients.getIngredientQuality(currentRecipe) + ingredients.getCookingQuality(currentRecipe, distillRuns > 0);
if (currentRecipe.needsToAge() || ageTime > 0.5) {
quality += ingredients.getWoodQuality(currentRecipe, wood) + ingredients.getAgeQuality(currentRecipe, ageTime);
quality /= 4;
} else {
quality /= 2;
}
return Math.round(quality);
2013-04-30 01:23:29 +02:00
}
public int getQuality() {
2013-04-30 01:23:29 +02:00
return quality;
}
2013-07-03 18:06:13 +02:00
public boolean canDistill() {
2013-08-30 21:19:49 +02:00
if (currentRecipe != null) {
return currentRecipe.getDistillRuns() > distillRuns;
} else if (distillRuns >= 6) {
2013-07-03 18:06:13 +02:00
return false;
}
return true;
}
2013-05-28 16:25:06 +02:00
// return special effect
2014-09-03 01:05:53 +02:00
public ArrayList<BEffect> getEffects() {
2013-08-30 21:19:49 +02:00
if (currentRecipe != null && quality > 0) {
2013-08-14 20:08:55 +02:00
return currentRecipe.getEffects();
2013-05-28 16:25:06 +02:00
}
return null;
}
2013-08-30 21:19:49 +02:00
// Set unlabeled to true to hide the numbers in Lore
public void unLabel(ItemStack item) {
PotionMeta meta = (PotionMeta) item.getItemMeta();
if (meta.hasLore()) {
if (distillRuns > 0) {
addOrReplaceLore(meta, P.p.color("&7"), P.p.languageReader.get("Brew_Distilled"));
2013-08-30 21:19:49 +02:00
}
if (ageTime >= 1) {
addOrReplaceLore(meta, P.p.color("&7"), P.p.languageReader.get("Brew_BarrelRiped"));
2013-08-30 21:19:49 +02:00
}
item.setItemMeta(meta);
}
unlabeled = true;
}
2014-06-03 23:10:47 +02:00
public boolean isPersistent() {
return persistent;
}
// Make a potion persistent to not delete it when drinking it
public void makePersistent() {
persistent = true;
}
// Remove the Persistence Flag from a brew, so it will be normally deleted when drinking it
public void removePersistence() {
persistent = false;
}
2014-09-03 22:03:03 +02:00
public boolean isStatic() {
return stat;
}
// Set the Static flag, so potion is unchangeable
public void setStatic(boolean stat, ItemStack potion) {
this.stat = stat;
if (currentRecipe != null && canDistill()) {
if (stat) {
potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(false));
} else {
potion.setDurability(PotionColor.valueOf(currentRecipe.getColor()).getColorId(true));
}
}
}
// Distilling section ---------------
2013-04-28 23:57:41 +02:00
// distill all custom potions in the brewer
2013-07-03 18:06:13 +02:00
public static void distillAll(BrewerInventory inv, Boolean[] contents) {
2013-04-28 23:57:41 +02:00
int slot = 0;
while (slot < 3) {
2013-07-03 18:06:13 +02:00
if (contents[slot]) {
2013-08-30 21:19:49 +02:00
ItemStack slotItem = inv.getItem(slot);
PotionMeta potionMeta = (PotionMeta) slotItem.getItemMeta();
Brew brew = get(potionMeta);
brew.distillSlot(slotItem, potionMeta);
2013-04-28 23:57:41 +02:00
}
slot++;
}
}
// distill custom potion in given slot
2013-08-30 21:19:49 +02:00
public void distillSlot(ItemStack slotItem, PotionMeta potionMeta) {
2014-09-03 22:03:03 +02:00
if (stat) {
return;
}
2013-08-30 21:19:49 +02:00
distillRuns += 1;
2013-09-05 17:09:20 +02:00
BRecipe recipe = ingredients.getdistillRecipe(wood, ageTime);
if (recipe != null) {
2013-08-15 18:17:05 +02:00
// distillRuns will have an effect on the amount of alcohol, not the quality
2013-08-30 21:19:49 +02:00
currentRecipe = recipe;
2013-09-05 17:09:20 +02:00
quality = calcQuality();
2013-08-15 18:17:05 +02:00
2014-09-03 01:05:53 +02:00
addOrReplaceEffects(potionMeta, getEffects(), quality);
2013-08-30 21:19:49 +02:00
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
slotItem.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
2013-04-28 23:57:41 +02:00
} else {
2013-08-30 21:19:49 +02:00
quality = 0;
2014-09-03 01:05:53 +02:00
removeEffects(potionMeta);
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_DistillUndefined")));
2013-08-30 21:19:49 +02:00
slotItem.setDurability(PotionColor.GREY.getColorId(canDistill()));
2013-04-28 23:57:41 +02:00
}
2013-08-30 21:19:49 +02:00
// Distill Lore
if (currentRecipe != null) {
if (colorInBrewer != hasColorLore(potionMeta)) {
convertLore(potionMeta, colorInBrewer);
}
}
String prefix = P.p.color("&7");
if (colorInBrewer && currentRecipe != null) {
prefix = getQualityColor(ingredients.getDistillQuality(recipe, distillRuns));
}
updateDistillLore(prefix, potionMeta);
2013-04-28 23:57:41 +02:00
slotItem.setItemMeta(potionMeta);
}
// Ageing Section ------------------
2013-04-28 23:57:41 +02:00
2013-09-05 17:09:20 +02:00
public void age(ItemStack item, float time, byte woodType) {
2014-09-03 22:03:03 +02:00
if (stat) {
return;
}
2013-04-28 23:57:41 +02:00
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
2013-08-30 21:19:49 +02:00
ageTime += time;
// if younger than half a day, it shouldnt get aged form
if (ageTime > 0.5) {
2013-09-05 17:09:20 +02:00
if (wood == 0) {
wood = woodType;
} else {
if (wood != woodType) {
woodShift(time, woodType);
}
}
2013-08-30 21:19:49 +02:00
BRecipe recipe = ingredients.getAgeRecipe(wood, ageTime, distillRuns > 0);
if (recipe != null) {
currentRecipe = recipe;
2013-09-05 17:09:20 +02:00
quality = calcQuality();
2013-08-30 21:19:49 +02:00
2014-09-03 01:05:53 +02:00
addOrReplaceEffects(potionMeta, getEffects(), quality);
2013-08-30 21:19:49 +02:00
potionMeta.setDisplayName(P.p.color("&f" + recipe.getName(quality)));
item.setDurability(PotionColor.valueOf(recipe.getColor()).getColorId(canDistill()));
} else {
quality = 0;
2014-09-03 01:05:53 +02:00
removeEffects(potionMeta);
potionMeta.setDisplayName(P.p.color("&f" + P.p.languageReader.get("Brew_BadPotion")));
2013-08-30 21:19:49 +02:00
item.setDurability(PotionColor.GREY.getColorId(canDistill()));
2013-04-28 23:57:41 +02:00
}
2013-08-30 21:19:49 +02:00
}
2013-08-30 21:19:49 +02:00
// Lore
if (currentRecipe != null) {
if (colorInBarrels != hasColorLore(potionMeta)) {
2013-08-30 21:19:49 +02:00
convertLore(potionMeta, colorInBarrels);
}
2013-04-28 23:57:41 +02:00
}
2013-08-30 21:19:49 +02:00
if (ageTime >= 1) {
String prefix = P.p.color("&7");
if (colorInBarrels && currentRecipe != null) {
prefix = getQualityColor(ingredients.getAgeQuality(currentRecipe, ageTime));
2013-08-15 18:17:05 +02:00
}
2013-08-30 21:19:49 +02:00
updateAgeLore(prefix, potionMeta);
2013-08-15 18:17:05 +02:00
}
2013-09-05 17:09:20 +02:00
if (ageTime > 0.5) {
if (colorInBarrels && !unlabeled && currentRecipe != null) {
updateWoodLore(potionMeta);
}
}
2013-08-30 21:19:49 +02:00
item.setItemMeta(potionMeta);
2013-08-15 18:17:05 +02:00
}
2013-09-05 17:09:20 +02:00
// Slowly shift the wood of the Brew to the new Type
public void woodShift(float time, byte to) {
byte factor = 1;
if (ageTime > 5) {
factor = 2;
} else if (ageTime > 10) {
factor = 2;
factor += Math.round(ageTime / 10);
}
if (wood > to) {
wood -= time / factor;
if (wood < to) {
wood = to;
}
} else {
wood += time / factor;
if (wood > to) {
wood = to;
}
}
}
// Lore -----------
// Converts to/from qualitycolored Lore
public void convertLore(PotionMeta meta, Boolean toQuality) {
if (currentRecipe == null) {
return;
}
meta.setLore(null);
int quality;
String prefix = P.p.color("&7");
String lore;
2013-08-30 21:19:49 +02:00
// Ingredients
if (toQuality && !unlabeled) {
quality = ingredients.getIngredientQuality(currentRecipe);
prefix = getQualityColor(quality);
lore = P.p.languageReader.get("Brew_Ingredients");
addOrReplaceLore(meta, prefix, lore);
}
// Cooking
2013-08-30 21:19:49 +02:00
if (toQuality && !unlabeled) {
if (distillRuns > 0 == currentRecipe.needsDistilling()) {
quality = ingredients.getCookingQuality(currentRecipe, distillRuns > 0);
prefix = getQualityColor(quality) + ingredients.getCookedTime() + " " + P.p.languageReader.get("Brew_minute");
if (ingredients.getCookedTime() > 1) {
prefix = prefix + P.p.languageReader.get("Brew_MinutePluralPostfix");
}
lore = " " + P.p.languageReader.get("Brew_fermented");
addOrReplaceLore(meta, prefix, lore);
}
}
// Distilling
if (distillRuns > 0) {
if (toQuality) {
quality = ingredients.getDistillQuality(currentRecipe, distillRuns);
prefix = getQualityColor(quality);
}
updateDistillLore(prefix, meta);
}
// Ageing
if (ageTime >= 1) {
if (toQuality) {
quality = ingredients.getAgeQuality(currentRecipe, ageTime);
prefix = getQualityColor(quality);
}
updateAgeLore(prefix, meta);
}
2013-09-05 17:09:20 +02:00
// WoodType
if (toQuality && !unlabeled) {
if (ageTime > 0.5) {
updateWoodLore(meta);
}
}
}
// sets the DistillLore. Prefix is the color to be used
public void updateDistillLore(String prefix, PotionMeta meta) {
2013-08-30 21:19:49 +02:00
if (!unlabeled) {
if (distillRuns > 1) {
prefix = prefix + distillRuns + P.p.languageReader.get("Brew_-times") + " ";
2013-08-30 21:19:49 +02:00
}
}
addOrReplaceLore(meta, prefix, P.p.languageReader.get("Brew_Distilled"));
}
// sets the AgeLore. Prefix is the color to be used
public void updateAgeLore(String prefix, PotionMeta meta) {
2013-08-30 21:19:49 +02:00
if (!unlabeled) {
if (ageTime >= 1 && ageTime < 2) {
prefix = prefix + P.p.languageReader.get("Brew_OneYear") + " ";
2013-08-30 21:19:49 +02:00
} else if (ageTime < 201) {
prefix = prefix + (int) Math.floor(ageTime) + " " + P.p.languageReader.get("Brew_Years") + " ";
2013-08-30 21:19:49 +02:00
} else {
prefix = prefix + P.p.languageReader.get("Brew_HundredsOfYears") + " ";
2013-08-30 21:19:49 +02:00
}
}
addOrReplaceLore(meta, prefix, P.p.languageReader.get("Brew_BarrelRiped"));
}
2013-09-05 17:09:20 +02:00
// updates/sets the color on WoodLore
public void updateWoodLore(PotionMeta meta) {
if (currentRecipe.getWood() > 0) {
int quality = ingredients.getWoodQuality(currentRecipe, wood);
addOrReplaceLore(meta, getQualityColor(quality), P.p.languageReader.get("Brew_Woodtype"));
2013-09-05 17:09:20 +02:00
} else {
if (meta.hasLore()) {
List<String> existingLore = meta.getLore();
int index = indexOfSubstring(existingLore, P.p.languageReader.get("Brew_Woodtype"));
2013-09-05 17:09:20 +02:00
if (index > -1) {
existingLore.remove(index);
meta.setLore(existingLore);
}
}
}
}
// Adds or replaces a line of Lore. Searches for Substring lore and replaces it
2013-08-15 18:17:05 +02:00
public static void addOrReplaceLore(PotionMeta meta, String prefix, String lore) {
if (meta.hasLore()) {
List<String> existingLore = meta.getLore();
int index = indexOfSubstring(existingLore, lore);
if (index > -1) {
existingLore.set(index, prefix + lore);
} else {
existingLore.add(prefix + lore);
}
meta.setLore(existingLore);
return;
}
List<String> newLore = new ArrayList<String>();
newLore.add("");
newLore.add(prefix + lore);
meta.setLore(newLore);
}
2013-08-30 21:19:49 +02:00
// Adds the Effect names to the Items description
2014-09-03 01:05:53 +02:00
public static void addOrReplaceEffects(PotionMeta meta, ArrayList<BEffect> effects, int quality) {
2013-08-30 21:19:49 +02:00
if (effects != null) {
2014-09-03 01:05:53 +02:00
for (BEffect effect : effects) {
if (!effect.isHidden()) {
effect.writeInto(meta, quality);
}
}
}
}
// Removes all effects except regeneration which stores data
public static void removeEffects(PotionMeta meta) {
if (meta.hasCustomEffects()) {
for (PotionEffect effect : meta.getCustomEffects()) {
PotionEffectType type = effect.getType();
if (!type.equals(PotionEffectType.REGENERATION)) {
meta.removeCustomEffect(type);
2013-08-30 21:19:49 +02:00
}
}
}
}
// Returns the Index of a String from the list that contains this substring
2013-08-15 18:17:05 +02:00
public static int indexOfSubstring(List<String> list, String substring) {
for (int index = 0; index < list.size(); index++) {
String string = list.get(index);
if (string.contains(substring)) {
return index;
}
}
return -1;
}
// True if the PotionMeta has colored Lore
public static Boolean hasColorLore(PotionMeta meta) {
return meta.hasLore() && !meta.getLore().get(1).startsWith(P.p.color("&7"));
}
2013-08-15 18:17:05 +02:00
// gets the Color that represents a quality in Lore
public static String getQualityColor(int quality) {
String color;
if (quality > 8) {
color = "&a";
} else if (quality > 6) {
color = "&e";
} else if (quality > 4) {
color = "&6";
} else if (quality > 2) {
color = "&c";
} else {
color = "&4";
}
return P.p.color(color);
2013-08-14 20:08:55 +02:00
}
// Saves all data
public static void save(ConfigurationSection config) {
2013-09-04 23:32:09 +02:00
for (Map.Entry<Integer, Brew> entry : potions.entrySet()) {
int uid = entry.getKey();
Brew brew = entry.getValue();
ConfigurationSection idConfig = config.createSection("" + uid);
// not saving unneccessary data
if (brew.quality != 0) {
2013-04-30 21:41:16 +02:00
idConfig.set("quality", brew.quality);
}
if (brew.distillRuns != 0) {
2013-04-30 21:41:16 +02:00
idConfig.set("distillRuns", brew.distillRuns);
}
if (brew.ageTime != 0) {
2013-04-30 21:41:16 +02:00
idConfig.set("ageTime", brew.ageTime);
}
2013-09-05 17:09:20 +02:00
if (brew.wood != -1) {
idConfig.set("wood", brew.wood);
}
2013-05-28 16:25:06 +02:00
if (brew.currentRecipe != null) {
idConfig.set("recipe", brew.currentRecipe.getName(5));
2013-04-30 21:41:16 +02:00
}
2013-08-30 21:19:49 +02:00
if (brew.unlabeled) {
idConfig.set("unlabeled", true);
}
2014-06-03 23:10:47 +02:00
if (brew.persistent) {
idConfig.set("persist", true);
}
2014-09-03 22:03:03 +02:00
if (brew.stat) {
idConfig.set("stat", true);
}
// save the ingredients
2013-09-04 23:32:09 +02:00
idConfig.set("ingId", brew.ingredients.save(config.getParent()));
2013-04-30 21:41:16 +02:00
}
}
public static enum PotionColor {
2013-05-28 16:25:06 +02:00
PINK(1),
CYAN(2),
ORANGE(3),
GREEN(4),
BRIGHT_RED(5),
BLUE(6),
BLACK(8),
RED(9),
GREY(10),
WATER(11),
DARK_RED(12),
BRIGHT_GREY(14);
2013-04-28 23:57:41 +02:00
private final int colorId;
private PotionColor(int colorId) {
this.colorId = colorId;
}
// gets the Damage Value, that sets a color on the potion
// offset +32 is not accepted by brewer, so not further destillable
public short getColorId(boolean destillable) {
if (destillable) {
2013-04-28 23:57:41 +02:00
return (short) (colorId + 64);
}
return (short) (colorId + 32);
}
}
}