Added cmd Copy

This commit is contained in:
Sn0wStorm
2013-08-20 23:19:23 +02:00
parent b7d0b73aa0
commit 925107fdfc
3 changed files with 99 additions and 22 deletions
+30 -10
View File
@@ -72,16 +72,16 @@ public class Brew {
}
// returns a Brew by ItemStack
/* public static Brew get(ItemStack item) {
* if (item.getTypeId() == 373) {
* if (item.hasItemMeta()) {
* PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
* return get(potionMeta);
* }
* }
* return null;
* }
*/
public static Brew get(ItemStack item) {
if (item.getTypeId() == 373) {
if (item.hasItemMeta()) {
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
return get(potionMeta);
}
}
return null;
}
// returns UID of custom Potion item
public static int getUID(ItemStack item) {
@@ -116,6 +116,26 @@ public class Brew {
return uid;
}
// 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;
return brew;
}
// calculate alcohol from recipe
public int calcAlcohol() {
if (currentRecipe != null) {