package net.minecraft.client.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.multiplayer.ClientLevel; 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.Mth; import net.minecraft.util.RandomSource; @Environment(EnvType.CLIENT) public class WaterCurrentDownParticle extends SingleQuadParticle { private float angle; private WaterCurrentDownParticle(final ClientLevel level, final double x, final double y, final double z, final TextureAtlasSprite sprite) { super(level, x, y, z, sprite); this.lifetime = (int)(this.random.nextFloat() * 60.0F) + 30; this.hasPhysics = false; this.xd = 0.0; this.yd = -0.05; this.zd = 0.0; this.setSize(0.02F, 0.02F); this.quadSize = this.quadSize * (this.random.nextFloat() * 0.6F + 0.2F); this.gravity = 0.002F; } @Override public SingleQuadParticle.Layer getLayer() { return SingleQuadParticle.Layer.OPAQUE; } @Override public void tick() { this.xo = this.x; this.yo = this.y; this.zo = this.z; if (this.age++ >= this.lifetime) { this.remove(); } else { float radius = 0.6F; this.xd = this.xd + 0.6F * Mth.cos(this.angle); this.zd = this.zd + 0.6F * Mth.sin(this.angle); this.xd *= 0.07; this.zd *= 0.07; this.move(this.xd, this.yd, this.zd); if (!this.level.getFluidState(BlockPos.containing(this.x, this.y, this.z)).is(FluidTags.WATER) || this.onGround) { this.remove(); } this.angle += 0.08F; } } @Environment(EnvType.CLIENT) public static class Provider implements ParticleProvider { private final SpriteSet sprite; public Provider(final SpriteSet sprite) { this.sprite = sprite; } public Particle createParticle( final SimpleParticleType options, final ClientLevel level, final double x, final double y, final double z, final double xAux, final double yAux, final double zAux, final RandomSource random ) { return new WaterCurrentDownParticle(level, x, y, z, this.sprite.get(random)); } } }