Search in sources :

Example 1 with SmallPotionEffect

use of net.mcft.copy.betterstorage.misc.SmallPotionEffect in project BetterStorage by copygirl.

the class ItemDrinkingHelmet method use.

public static void use(EntityPlayer player) {
    ItemStack drinkingHelmet = getDrinkingHelmet(player);
    if (drinkingHelmet == null)
        return;
    int uses = StackUtils.get(drinkingHelmet, 0, "uses");
    if (uses <= 0)
        return;
    ItemStack[] potions = StackUtils.getStackContents(drinkingHelmet, 2);
    List<PotionEffect> potionEffects = new ArrayList<PotionEffect>();
    for (ItemStack item : potions) if (item.getItem() instanceof ItemPotion) {
        List<PotionEffect> effects = ((ItemPotion) item.getItem()).getEffects(item);
        if (effects != null)
            potionEffects.addAll(effects);
    }
    for (PotionEffect effect : potionEffects) {
        Potion potion = Potion.potionTypes[effect.getPotionID()];
        PotionEffect active = player.getActivePotionEffect(potion);
        effect = new SmallPotionEffect(effect, active);
        player.addPotionEffect(effect);
    }
    player.worldObj.playSoundAtEntity(player, "random.drink", 0.5F, 0.9F + player.worldObj.rand.nextFloat() * 0.1F);
    if (--uses <= 0)
        setPotions(drinkingHelmet, null);
    else
        StackUtils.set(drinkingHelmet, uses, "uses");
}
Also used : SmallPotionEffect(net.mcft.copy.betterstorage.misc.SmallPotionEffect) ItemPotion(net.minecraft.item.ItemPotion) PotionEffect(net.minecraft.potion.PotionEffect) SmallPotionEffect(net.mcft.copy.betterstorage.misc.SmallPotionEffect) ItemPotion(net.minecraft.item.ItemPotion) Potion(net.minecraft.potion.Potion) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 SmallPotionEffect (net.mcft.copy.betterstorage.misc.SmallPotionEffect)1 ItemPotion (net.minecraft.item.ItemPotion)1 ItemStack (net.minecraft.item.ItemStack)1 Potion (net.minecraft.potion.Potion)1 PotionEffect (net.minecraft.potion.PotionEffect)1