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