protected void updatePotionEffects()
    {
        Iterator var1 = this.activePotionsMap.keySet().iterator();

        while (var1.hasNext())
        {
            Integer var2 = (Integer)var1.next();
            PotionEffect var3 = (PotionEffect)this.activePotionsMap.get(var2);

            if (!var3.onUpdate(this) && !this.worldObj.isRemote)
            {
                var1.remove();
                this.onFinishedPotionEffect(var3);
            }
        }

        int var9;

        if (this.potionsNeedUpdate)
        {
            if (!this.worldObj.isRemote)
            {
                if (!this.activePotionsMap.isEmpty())
                {
                    var9 = PotionHelper.func_40354_a(this.activePotionsMap.values());
                    this.dataWatcher.updateObject(8, Integer.valueOf(var9));
                }
                else
                {
                    this.dataWatcher.updateObject(8, Integer.valueOf(0));
                }
            }

            this.potionsNeedUpdate = false;
        }

        if (this.rand.nextBoolean())
        {
            var9 = this.dataWatcher.getWatchableObjectInt(8);

            if (var9 > 0)
            {
                double var10 = (double)(var9 >> 16 & 255) / 255.0D;
                double var5 = (double)(var9 >> 8 & 255) / 255.0D;
                double var7 = (double)(var9 >> 0 & 255) / 255.0D;
                this.worldObj.spawnParticle("mobSpell", this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height - (double)this.yOffset, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, var10, var5, var7);
            }
        }
    }