use of com.bewitchment.api.cauldron.brew.IBrew in project Bewitchment by Um-Mitternacht.
the class BrewUtils method createBrew.
public static ItemStack createBrew(BrewRegistry.Brew enu, BrewEffect... effects) {
ItemStack stack = new ItemStack(enu.getItem());
NBTTagList list = addBrewData(stack);
for (BrewEffect effect : effects) {
NBTTagCompound tag = new NBTTagCompound();
IBrew brew = effect.getBrew();
tag.setString(BREW_ID, BrewRegistry.getBrewResource(brew).toString());
tag.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
tag.setInteger(BREW_DURATION, effect.getDuration());
list.appendTag(tag);
}
return stack;
}
use of com.bewitchment.api.cauldron.brew.IBrew in project Bewitchment by Um-Mitternacht.
the class BrewUtils method addBrewTooltip.
@SideOnly(Side.CLIENT)
public static void addBrewTooltip(ItemStack stack, List<String> tooltip) {
List<BrewEffect> brewsFromStack = BrewUtils.getBrewsFromStack(stack);
for (BrewEffect effect : brewsFromStack) {
IBrew brew = effect.getBrew();
String name = " - " + I18n.format("brew." + brew.getName() + ".tooltip") + " ";
String amplifier = (effect.getAmplifier() <= 0) ? "" : (RomanNumber.getRoman(effect.getAmplifier())) + " ";
String duration = effect.isInstant() ? I18n.format("brew.instant") : StringUtils.ticksToElapsedTime(effect.getDuration());
tooltip.add(TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC + name + amplifier + "(" + duration + ")");
}
if (brewsFromStack.isEmpty()) {
tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + "---");
}
}
use of com.bewitchment.api.cauldron.brew.IBrew in project Bewitchment by Um-Mitternacht.
the class BrewUtils method addBrewEffect.
public static ItemStack addBrewEffect(ItemStack stack, BrewEffect effect) {
NBTTagList list = addBrewData(stack);
NBTTagCompound tag = new NBTTagCompound();
IBrew brew = effect.getBrew();
tag.setString(BREW_ID, BrewRegistry.getBrewResource(brew).toString());
tag.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
tag.setInteger(BREW_DURATION, effect.getDuration());
list.appendTag(tag);
return stack;
}
use of com.bewitchment.api.cauldron.brew.IBrew in project Bewitchment by Um-Mitternacht.
the class BrewUtils method deSerialize.
public static Tuple<List<BrewEffect>, List<PotionEffect>> deSerialize(NBTTagCompound compound) {
List<PotionEffect> potionEffects = PotionUtils.getEffectsFromTag(compound);
List<BrewEffect> brewEffects = new ArrayList<>();
Tuple<List<BrewEffect>, List<PotionEffect>> tuple = new Tuple<>(brewEffects, potionEffects);
NBTTagList list = (NBTTagList) compound.getTag(BREW_DATA);
for (int i = 0, size = list.tagCount(); i < size; i++) {
NBTTagCompound tag = list.getCompoundTagAt(i);
IBrew brew = BrewRegistry.getRegisteredBrew(tag.getString(BREW_ID));
int duration = tag.getInteger(BREW_DURATION);
int amplifier = tag.getInteger(BREW_AMPLIFIER);
brewEffects.add(new BrewEffect(brew, duration, amplifier));
}
return tuple;
}
use of com.bewitchment.api.cauldron.brew.IBrew in project Bewitchment by Um-Mitternacht.
the class BrewUtils method appendBrews.
public static void appendBrews(NBTTagCompound tag, Collection<BrewEffect> effects) {
NBTTagList list = new NBTTagList();
tag.setTag(BREW_DATA, list);
for (BrewEffect effect : effects) {
NBTTagCompound compound = new NBTTagCompound();
IBrew brew = effect.getBrew();
compound.setString(BREW_ID, BrewRegistry.getBrewResource(brew).toString());
compound.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
compound.setInteger(BREW_DURATION, effect.getDuration());
list.appendTag(compound);
}
}
Aggregations