package net.mcft.copy.betterstorage.misc;

import net.mcft.copy.betterstorage.item.ItemDrinkingHelmet;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;

public class SmallPotionEffect extends PotionEffect {
	
	public SmallPotionEffect(int potionID, int duration, int amplifier) {
		super(potionID, Math.max(1, duration / ItemDrinkingHelmet.maxUses), amplifier);
	}
	public SmallPotionEffect(PotionEffect effect, PotionEffect active) {
		this(effect.getPotionID(), getDuration(effect, active), effect.getAmplifier());
	}
	private static int getDuration(PotionEffect effect, PotionEffect active) {
		return ((active != null) ? (effect.getDuration() + active.getDuration()) : effect.getDuration());
	}
	
	@Override
	public void performEffect(EntityLivingBase entity) {
		int smallEffect = 6 * (getAmplifier() + 1) / ItemDrinkingHelmet.maxUses;
		Potion potion = Potion.potionTypes[getPotionID()];
		if (entity.isEntityUndead() ? (potion == Potion.heal) : (potion == Potion.harm))
			entity.attackEntityFrom(DamageSource.magic, smallEffect);
		else if (potion == Potion.heal) entity.heal(smallEffect);
		else super.performEffect(entity);
	}
	
}

@@ -549,12 +549,13 @@
 %7B%0A%09%09
-this
+super
 (eff
@@ -718,82 +718,86 @@
 urn 
-((active != null) ? (effect.getDuration() + active.getDuration()) : effect
+effect.getDuration() / ItemDrinkingHelmet.maxUses + ((active != null) ? active
 .get
@@ -806,16 +806,20 @@
 ration()
+ : 0
 );%0A%09%7D%0A%09%0A

Fix drinking helmet potion effects not stacking