Search in sources :

Example 1 with EnchantParticle

use of cn.nukkit.level.particle.EnchantParticle in project Nukkit by Nukkit.

the class EntityExpBottle method onUpdate.

@Override
public boolean onUpdate(int currentTick) {
    if (this.closed) {
        return false;
    }
    this.timing.startTiming();
    int tickDiff = currentTick - this.lastUpdate;
    boolean hasUpdate = super.onUpdate(currentTick);
    if (this.age > 1200) {
        this.kill();
        hasUpdate = true;
    }
    if (this.isCollided) {
        this.kill();
        Particle particle1 = new EnchantParticle(this);
        this.getLevel().addParticle(particle1);
        Particle particle2 = new SpellParticle(this, 0x00385dc6);
        this.getLevel().addParticle(particle2);
        hasUpdate = true;
        NukkitRandom random = new NukkitRandom();
        int add = 1;
        for (int ii = 1; ii <= random.nextRange(3, 11); ii += add) {
            getLevel().dropExpOrb(this, add);
            add = random.nextRange(1, 3);
        }
    }
    this.timing.stopTiming();
    return hasUpdate;
}
Also used : EnchantParticle(cn.nukkit.level.particle.EnchantParticle) SpellParticle(cn.nukkit.level.particle.SpellParticle) Particle(cn.nukkit.level.particle.Particle) SpellParticle(cn.nukkit.level.particle.SpellParticle) EnchantParticle(cn.nukkit.level.particle.EnchantParticle) NukkitRandom(cn.nukkit.math.NukkitRandom)

Aggregations

EnchantParticle (cn.nukkit.level.particle.EnchantParticle)1 Particle (cn.nukkit.level.particle.Particle)1 SpellParticle (cn.nukkit.level.particle.SpellParticle)1 NukkitRandom (cn.nukkit.math.NukkitRandom)1