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;
}
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);
}
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;
}
}
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;
}
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;
}
}
Aggregations