2025-11-24 22:52:51 +03:00

69 lines
2.4 KiB
Java

/*
* Decompiled with CFR 0.152.
*/
package net.minecraft.client.particle;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SingleQuadParticle;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.RandomSource;
public class BubbleParticle
extends SingleQuadParticle {
private BubbleParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, TextureAtlasSprite sprite) {
super(level, x, y, z, sprite);
this.setSize(0.02f, 0.02f);
this.quadSize *= this.random.nextFloat() * 0.6f + 0.2f;
this.xd = xa * (double)0.2f + (Math.random() * 2.0 - 1.0) * (double)0.02f;
this.yd = ya * (double)0.2f + (Math.random() * 2.0 - 1.0) * (double)0.02f;
this.zd = za * (double)0.2f + (Math.random() * 2.0 - 1.0) * (double)0.02f;
this.lifetime = (int)(8.0 / (Math.random() * 0.8 + 0.2));
}
@Override
public void tick() {
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.lifetime-- <= 0) {
this.remove();
return;
}
this.yd += 0.002;
this.move(this.xd, this.yd, this.zd);
this.xd *= (double)0.85f;
this.yd *= (double)0.85f;
this.zd *= (double)0.85f;
if (!this.level.getFluidState(BlockPos.containing(this.x, this.y, this.z)).is(FluidTags.WATER)) {
this.remove();
}
}
@Override
public SingleQuadParticle.Layer getLayer() {
return SingleQuadParticle.Layer.OPAQUE;
}
public static class Provider
implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprite;
public Provider(SpriteSet sprite) {
this.sprite = sprite;
}
@Override
public Particle createParticle(SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random) {
BubbleParticle particle = new BubbleParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
return particle;
}
}
}