Search in sources :

Example 1 with BrewEffect

use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.

the class BrewUtils method createBrew.

public static ItemStack createBrew(Item item, BrewEffect... effects) {
    ItemStack stack = new ItemStack(item);
    NBTTagList list = addBrewData(stack);
    for (BrewEffect effect : effects) {
        NBTTagCompound tag = new NBTTagCompound();
        IBrew brew = effect.getBrew();
        tag.setInteger(BREW_ID, BrewRegistry.getBrewId(brew));
        tag.setInteger(BREW_AMPLIFIER, effect.getAmplifier());
        tag.setInteger(BREW_DURATION, effect.getDuration());
        list.appendTag(tag);
    }
    return stack;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) BrewEffect(com.witchworks.api.item.BrewEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) IBrew(com.witchworks.api.item.IBrew)

Example 2 with BrewEffect

use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.

the class BrewUtils method serialize.

public static NBTTagCompound serialize(Collection<Object> collection) {
    List<BrewEffect> brewEffects = new ArrayList<>();
    List<PotionEffect> potionEffects = new ArrayList<>();
    for (Object brew : collection) {
        if (brew instanceof BrewEffect) {
            brewEffects.add((BrewEffect) brew);
        } else if (brew instanceof PotionEffect) {
            potionEffects.add((PotionEffect) brew);
        }
    }
    NBTTagCompound compound = new NBTTagCompound();
    appendPotions(compound, mixPotions(potionEffects));
    appendBrews(compound, mixBrews(brewEffects));
    return compound;
}
Also used : BrewEffect(com.witchworks.api.item.BrewEffect) PotionEffect(net.minecraft.potion.PotionEffect) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 3 with BrewEffect

use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.

the class ModBrews method init.

public static void init() {
    SHELL_ARMOR = BrewRegistry.registerBrew(new ShellArmorBrew());
    BrewRegistry.addDefault(new BrewEffect(SHELL_ARMOR, 2500, 0));
    INNER_FIRE = BrewRegistry.registerBrew(new InnerFireBrew());
    BrewRegistry.addDefault(new BrewEffect(INNER_FIRE, 1500, 0));
    SPIDER_NIGHTMARE = BrewRegistry.registerBrew(new SpiderNightmareBrew());
    BrewRegistry.addDefault(new BrewEffect(SPIDER_NIGHTMARE, 500, 0));
    EXTINGUISH = BrewRegistry.registerBrew(new ExtinguishBrew());
    BrewRegistry.addDefault(new BrewEffect(EXTINGUISH, 500, 0));
    WARWATER = BrewRegistry.registerBrew(new WarWaterBrew());
    BrewRegistry.addDefault(new BrewEffect(WARWATER, 1500, 0));
    FROSTBITE = BrewRegistry.registerBrew(new FrostbiteBrew());
    BrewRegistry.addDefault(new BrewEffect(FROSTBITE, 500, 0));
}
Also used : BrewEffect(com.witchworks.api.item.BrewEffect)

Example 4 with BrewEffect

use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.

the class BrewSimpleModifier method apply.

@Override
public boolean apply(List<Object> brews, Object current) {
    if (current instanceof PotionEffect) {
        PotionEffect effect = (PotionEffect) current;
        if (effect.getDuration() < 9600) {
            int hue = MathHelper.clamp(effect.getDuration() + duration, 0, 9600);
            effect.combine(new PotionEffect(effect.getPotion(), hue, effect.getAmplifier()));
        }
        if (effect.getAmplifier() < 3) {
            int hue = MathHelper.clamp(effect.getAmplifier() + amplifier, 0, 3);
            effect.combine(new PotionEffect(effect.getPotion(), effect.getDuration(), hue));
        }
    } else if (current instanceof BrewEffect) {
        BrewEffect effect = (BrewEffect) current;
        if (effect.getDuration() < 9600) {
            int hue = MathHelper.clamp(effect.getDuration() + duration, 0, 9600);
            effect.setDuration(hue);
        }
        if (effect.getAmplifier() < 3) {
            int hue = MathHelper.clamp(effect.getAmplifier() + amplifier, 0, 3);
            effect.setAmplifier(hue);
        }
    }
    return true;
}
Also used : BrewEffect(com.witchworks.api.item.BrewEffect) PotionEffect(net.minecraft.potion.PotionEffect)

Example 5 with BrewEffect

use of com.witchworks.api.item.BrewEffect in project Witchworks by Um-Mitternacht.

the class BrewStorageHandler method addEntityBrewEffect.

/**
	 * Add a BrewEffect to the entity.
	 *
	 * @param entity The entity
	 * @param effect The effect
	 */
public static void addEntityBrewEffect(EntityLivingBase entity, BrewEffect effect) {
    Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
    if (optional.isPresent()) {
        Map<IBrew, BrewEffect> effectMap = optional.get().getBrews();
        BrewEffect out = effectMap.get(effect.getBrew());
        if (out == null || effect.getDuration() > out.getDuration()) {
            effectMap.put(effect.getBrew(), effect);
        }
        optional.get().setBrews(effectMap);
    }
}
Also used : BrewEffect(com.witchworks.api.item.BrewEffect) IBrew(com.witchworks.api.item.IBrew)

Aggregations

BrewEffect (com.witchworks.api.item.BrewEffect)10 IBrew (com.witchworks.api.item.IBrew)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 NBTTagList (net.minecraft.nbt.NBTTagList)4 PotionEffect (net.minecraft.potion.PotionEffect)3 ItemStack (net.minecraft.item.ItemStack)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 Lists (com.google.common.collect.Lists)1 BrewRegistry (com.witchworks.api.BrewRegistry)1 RomanNumber (com.witchworks.api.helper.RomanNumber)1 NBTHelper (com.witchworks.api.item.NBTHelper)1 IBrewStorage (com.witchworks.common.core.capability.potion.IBrewStorage)1 PotionMessage (com.witchworks.common.core.net.PotionMessage)1 java.util (java.util)1 HashMap (java.util.HashMap)1 I18n (net.minecraft.client.resources.I18n)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)1 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1