Search in sources :

Example 1 with AlchemyPotionHelper

use of WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper in project BloodMagic by WayofTime.

the class CombinedPotionRegistry method applyPotionEffect.

public static ItemStack applyPotionEffect(ItemStack stack) {
    if (stack == null || !(stack.getItem() instanceof AlchemyFlask)) {
        return null;
    }
    List<AlchemyPotionHelper> list = AlchemyFlask.getEffects(stack);
    if (list == null) {
        return stack;
    }
    boolean isDone = false;
    for (AlchemyPotionHelper helper1 : list) {
        if (isDone) {
            continue;
        }
        for (int i = 0; i < list.size(); i++) {
            if (isDone) {
                continue;
            }
            AlchemyPotionHelper helper2 = list.get(i);
            PotionEffect potEffect = getResultantPotion(helper1, helper2);
            if (potEffect != null) {
                AlchemyPotionHelper potHelper = new AlchemyPotionHelper(potEffect.getPotionID(), potEffect.getDuration(), 0, potEffect.getAmplifier());
                list.remove(helper1);
                list.remove(helper2);
                list.add(potHelper);
                isDone = true;
            }
        }
    }
    if (isDone) {
        AlchemyFlask.setEffects(stack, list);
        return stack;
    }
    return null;
}
Also used : AlchemyPotionHelper(WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper) PotionEffect(net.minecraft.potion.PotionEffect) AlchemyFlask(WayofTime.alchemicalWizardry.common.items.potion.AlchemyFlask)

Example 2 with AlchemyPotionHelper

use of WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper in project BloodMagic by WayofTime.

the class AlchemyFlask method setEffects.

public static void setEffects(ItemStack par1ItemStack, List<AlchemyPotionHelper> list) {
    NBTTagCompound itemTag = par1ItemStack.getTagCompound();
    if (itemTag == null) {
        par1ItemStack.setTagCompound(new NBTTagCompound());
    }
    NBTTagList nbttaglist = new NBTTagList();
    for (AlchemyPotionHelper aph : list) {
        nbttaglist.appendTag(AlchemyPotionHelper.setEffectToNBT(aph));
    }
    par1ItemStack.getTagCompound().setTag("CustomFlaskEffects", nbttaglist);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) AlchemyPotionHelper(WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 3 with AlchemyPotionHelper

use of WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper in project BloodMagic by WayofTime.

the class AlchemyFlask method getEffects.

public static ArrayList<AlchemyPotionHelper> getEffects(ItemStack par1ItemStack) {
    if (par1ItemStack.hasTagCompound() && par1ItemStack.getTagCompound().hasKey("CustomFlaskEffects")) {
        ArrayList<AlchemyPotionHelper> arraylist = new ArrayList();
        NBTTagList nbttaglist = par1ItemStack.getTagCompound().getTagList("CustomFlaskEffects", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < nbttaglist.tagCount(); ++i) {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            arraylist.add(AlchemyPotionHelper.readEffectFromNBT(nbttagcompound));
        }
        return arraylist;
    } else {
        return null;
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) AlchemyPotionHelper(WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper) ArrayList(java.util.ArrayList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 4 with AlchemyPotionHelper

use of WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper in project BloodMagic by WayofTime.

the class CombinedPotionRegistry method hasCombinablePotionEffect.

public static boolean hasCombinablePotionEffect(ItemStack stack) {
    if (stack == null || !(stack.getItem() instanceof AlchemyFlask)) {
        return false;
    }
    List<AlchemyPotionHelper> list = AlchemyFlask.getEffects(stack);
    if (list == null) {
        return false;
    }
    for (AlchemyPotionHelper helper1 : list) {
        for (AlchemyPotionHelper helper2 : list) {
            int pot1 = helper1.getPotionID();
            int pot2 = helper2.getPotionID();
            if (isRecipeValid(pot1, pot2)) {
                return true;
            }
        }
    }
    return false;
}
Also used : AlchemyPotionHelper(WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper) AlchemyFlask(WayofTime.alchemicalWizardry.common.items.potion.AlchemyFlask)

Example 5 with AlchemyPotionHelper

use of WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper in project BloodMagic by WayofTime.

the class AlchemyFlask method addPotionEffect.

public boolean addPotionEffect(ItemStack par1ItemStack, int potionID, int tickDuration) {
    ArrayList<AlchemyPotionHelper> list = getEffects(par1ItemStack);
    if (list != null) {
        for (AlchemyPotionHelper aph : list) {
            if (aph.getPotionID() == potionID) {
                return false;
            }
        }
        list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0));
        setEffects(par1ItemStack, list);
        return true;
    } else {
        list = new ArrayList();
        list.add(new AlchemyPotionHelper(potionID, tickDuration, 0, 0));
        setEffects(par1ItemStack, list);
        return true;
    }
}
Also used : AlchemyPotionHelper(WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper) ArrayList(java.util.ArrayList)

Aggregations

AlchemyPotionHelper (WayofTime.alchemicalWizardry.api.alchemy.AlchemyPotionHelper)5 AlchemyFlask (WayofTime.alchemicalWizardry.common.items.potion.AlchemyFlask)2 ArrayList (java.util.ArrayList)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 NBTTagList (net.minecraft.nbt.NBTTagList)2 PotionEffect (net.minecraft.potion.PotionEffect)1