Search in sources :

Example 1 with IBrew

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;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) IBrew(com.bewitchment.api.cauldron.brew.IBrew)

Example 2 with IBrew

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 + "---");
    }
}
Also used : IBrew(com.bewitchment.api.cauldron.brew.IBrew) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with IBrew

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;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBrew(com.bewitchment.api.cauldron.brew.IBrew)

Example 4 with IBrew

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;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NBTTagList(net.minecraft.nbt.NBTTagList) Tuple(net.minecraft.util.Tuple) IBrew(com.bewitchment.api.cauldron.brew.IBrew)

Example 5 with IBrew

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBrew(com.bewitchment.api.cauldron.brew.IBrew)

Aggregations

IBrew (com.bewitchment.api.cauldron.brew.IBrew)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 NBTTagList (net.minecraft.nbt.NBTTagList)5 BrewEffect (com.bewitchment.common.brew.BrewEffect)3 IBrewStorage (com.bewitchment.api.capability.IBrewStorage)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 Minecraft (net.minecraft.client.Minecraft)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 ItemStack (net.minecraft.item.ItemStack)1 PotionEffect (net.minecraft.potion.PotionEffect)1 Tuple (net.minecraft.util.Tuple)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1