Java Code Examples for net.minecraft.potion.PotionEffect.onUpdate()

The following are Jave code examples for showing how to use onUpdate() of the net.minecraft.potion.PotionEffect class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DecompiledMinecraft   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
protected void updatePotionEffects()
{
    Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator();

    while (iterator.hasNext())
    {
        Integer integer = (Integer)iterator.next();
        PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer);

        if (!potioneffect.onUpdate(this))
        {
            if (!this.worldObj.isRemote)
            {
                iterator.remove();
                this.onFinishedPotionEffect(potioneffect);
            }
        }
        else if (potioneffect.getDuration() % 600 == 0)
        {
            this.onChangedPotionEffect(potioneffect, false);
        }
    }

    if (this.potionsNeedUpdate)
    {
        if (!this.worldObj.isRemote)
        {
            this.updatePotionMetadata();
        }

        this.potionsNeedUpdate = false;
    }

    int i = this.dataWatcher.getWatchableObjectInt(7);
    boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0;

    if (i > 0)
    {
        boolean flag = false;

        if (!this.isInvisible())
        {
            flag = this.rand.nextBoolean();
        }
        else
        {
            flag = this.rand.nextInt(15) == 0;
        }

        if (flag1)
        {
            flag &= this.rand.nextInt(5) == 0;
        }

        if (flag && i > 0)
        {
            double d0 = (double)(i >> 16 & 255) / 255.0D;
            double d1 = (double)(i >> 8 & 255) / 255.0D;
            double d2 = (double)(i >> 0 & 255) / 255.0D;
            this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
        }
    }
}
 
Example 2
Project: DecompiledMinecraft   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
protected void updatePotionEffects()
{
    Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator();

    while (iterator.hasNext())
    {
        Integer integer = (Integer)iterator.next();
        PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer);

        if (!potioneffect.onUpdate(this))
        {
            if (!this.worldObj.isRemote)
            {
                iterator.remove();
                this.onFinishedPotionEffect(potioneffect);
            }
        }
        else if (potioneffect.getDuration() % 600 == 0)
        {
            this.onChangedPotionEffect(potioneffect, false);
        }
    }

    if (this.potionsNeedUpdate)
    {
        if (!this.worldObj.isRemote)
        {
            this.updatePotionMetadata();
        }

        this.potionsNeedUpdate = false;
    }

    int i = this.dataWatcher.getWatchableObjectInt(7);
    boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0;

    if (i > 0)
    {
        boolean flag = false;

        if (!this.isInvisible())
        {
            flag = this.rand.nextBoolean();
        }
        else
        {
            flag = this.rand.nextInt(15) == 0;
        }

        if (flag1)
        {
            flag &= this.rand.nextInt(5) == 0;
        }

        if (flag && i > 0)
        {
            double d0 = (double)(i >> 16 & 255) / 255.0D;
            double d1 = (double)(i >> 8 & 255) / 255.0D;
            double d2 = (double)(i >> 0 & 255) / 255.0D;
            this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
        }
    }
}
 
Example 3
Project: BaseClient   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
protected void updatePotionEffects()
{
    Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator();

    while (iterator.hasNext())
    {
        Integer integer = (Integer)iterator.next();
        PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer);

        if (!potioneffect.onUpdate(this))
        {
            if (!this.worldObj.isRemote)
            {
                iterator.remove();
                this.onFinishedPotionEffect(potioneffect);
            }
        }
        else if (potioneffect.getDuration() % 600 == 0)
        {
            this.onChangedPotionEffect(potioneffect, false);
        }
    }

    if (this.potionsNeedUpdate)
    {
        if (!this.worldObj.isRemote)
        {
            this.updatePotionMetadata();
        }

        this.potionsNeedUpdate = false;
    }

    int i = this.dataWatcher.getWatchableObjectInt(7);
    boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0;

    if (i > 0)
    {
        boolean flag = false;

        if (!this.isInvisible())
        {
            flag = this.rand.nextBoolean();
        }
        else
        {
            flag = this.rand.nextInt(15) == 0;
        }

        if (flag1)
        {
            flag &= this.rand.nextInt(5) == 0;
        }

        if (flag && i > 0)
        {
            double d0 = (double)(i >> 16 & 255) / 255.0D;
            double d1 = (double)(i >> 8 & 255) / 255.0D;
            double d2 = (double)(i >> 0 & 255) / 255.0D;
            this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
        }
    }
}
 
Example 4
Project: BaseClient   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
protected void updatePotionEffects()
{
    Iterator<Integer> iterator = this.activePotionsMap.keySet().iterator();

    while (iterator.hasNext())
    {
        Integer integer = (Integer)iterator.next();
        PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(integer);

        if (!potioneffect.onUpdate(this))
        {
            if (!this.worldObj.isRemote)
            {
                iterator.remove();
                this.onFinishedPotionEffect(potioneffect);
            }
        }
        else if (potioneffect.getDuration() % 600 == 0)
        {
            this.onChangedPotionEffect(potioneffect, false);
        }
    }

    if (this.potionsNeedUpdate)
    {
        if (!this.worldObj.isRemote)
        {
            this.updatePotionMetadata();
        }

        this.potionsNeedUpdate = false;
    }

    int i = this.dataWatcher.getWatchableObjectInt(7);
    boolean flag1 = this.dataWatcher.getWatchableObjectByte(8) > 0;

    if (i > 0)
    {
        boolean flag = false;

        if (!this.isInvisible())
        {
            flag = this.rand.nextBoolean();
        }
        else
        {
            flag = this.rand.nextInt(15) == 0;
        }

        if (flag1)
        {
            flag &= this.rand.nextInt(5) == 0;
        }

        if (flag && i > 0)
        {
            double d0 = (double)(i >> 16 & 255) / 255.0D;
            double d1 = (double)(i >> 8 & 255) / 255.0D;
            double d2 = (double)(i >> 0 & 255) / 255.0D;
            this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
        }
    }
}
 
Example 5
Project: Backmemed   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
protected void updatePotionEffects()
{
    Iterator<Potion> iterator = this.activePotionsMap.keySet().iterator();

    try
    {
        while (iterator.hasNext())
        {
            Potion potion = (Potion)iterator.next();
            PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(potion);

            if (!potioneffect.onUpdate(this))
            {
                if (!this.world.isRemote)
                {
                    iterator.remove();
                    this.onFinishedPotionEffect(potioneffect);
                }
            }
            else if (potioneffect.getDuration() % 600 == 0)
            {
                this.onChangedPotionEffect(potioneffect, false);
            }
        }
    }
    catch (ConcurrentModificationException var11)
    {
        ;
    }

    if (this.potionsNeedUpdate)
    {
        if (!this.world.isRemote)
        {
            this.updatePotionMetadata();
        }

        this.potionsNeedUpdate = false;
    }

    int i = ((Integer)this.dataManager.get(POTION_EFFECTS)).intValue();
    boolean flag1 = ((Boolean)this.dataManager.get(HIDE_PARTICLES)).booleanValue();

    if (i > 0)
    {
        boolean flag;

        if (this.isInvisible())
        {
            flag = this.rand.nextInt(15) == 0;
        }
        else
        {
            flag = this.rand.nextBoolean();
        }

        if (flag1)
        {
            flag &= this.rand.nextInt(5) == 0;
        }

        if (flag && i > 0)
        {
            double d0 = (double)(i >> 16 & 255) / 255.0D;
            double d1 = (double)(i >> 8 & 255) / 255.0D;
            double d2 = (double)(i >> 0 & 255) / 255.0D;
            this.world.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
        }
    }
}
 
Example 6
Project: CustomWorldGen   File: EntityLivingBase.java   Source Code and License Vote up 4 votes
protected void updatePotionEffects()
{
    Iterator<Potion> iterator = this.activePotionsMap.keySet().iterator();

    while (iterator.hasNext())
    {
        Potion potion = (Potion)iterator.next();
        PotionEffect potioneffect = (PotionEffect)this.activePotionsMap.get(potion);

        if (!potioneffect.onUpdate(this))
        {
            if (!this.worldObj.isRemote)
            {
                iterator.remove();
                this.onFinishedPotionEffect(potioneffect);
            }
        }
        else if (potioneffect.getDuration() % 600 == 0)
        {
            this.onChangedPotionEffect(potioneffect, false);
        }
    }

    if (this.potionsNeedUpdate)
    {
        if (!this.worldObj.isRemote)
        {
            this.updatePotionMetadata();
        }

        this.potionsNeedUpdate = false;
    }

    int i = ((Integer)this.dataManager.get(POTION_EFFECTS)).intValue();
    boolean flag1 = ((Boolean)this.dataManager.get(HIDE_PARTICLES)).booleanValue();

    if (i > 0)
    {
        boolean flag;

        if (this.isInvisible())
        {
            flag = this.rand.nextInt(15) == 0;
        }
        else
        {
            flag = this.rand.nextBoolean();
        }

        if (flag1)
        {
            flag &= this.rand.nextInt(5) == 0;
        }

        if (flag && i > 0)
        {
            double d0 = (double)(i >> 16 & 255) / 255.0D;
            double d1 = (double)(i >> 8 & 255) / 255.0D;
            double d2 = (double)(i >> 0 & 255) / 255.0D;
            this.worldObj.spawnParticle(flag1 ? EnumParticleTypes.SPELL_MOB_AMBIENT : EnumParticleTypes.SPELL_MOB, this.posX + (this.rand.nextDouble() - 0.5D) * (double)this.width, this.posY + this.rand.nextDouble() * (double)this.height, this.posZ + (this.rand.nextDouble() - 0.5D) * (double)this.width, d0, d1, d2, new int[0]);
        }
    }
}