package net.minecraft.client.particle; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.SimpleParticleType; import net.minecraft.tags.FluidTags; import net.minecraft.util.Mth; @Environment(EnvType.CLIENT) public class WaterCurrentDownParticle extends TextureSheetParticle { private float angle; WaterCurrentDownParticle(ClientLevel clientLevel, double d, double e, double f) { super(clientLevel, d, e, f); this.lifetime = (int)(Math.random() * 60.0) + 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 ParticleRenderType getRenderType() { return ParticleRenderType.PARTICLE_SHEET_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 f = 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(SpriteSet sprites) { this.sprite = sprites; } public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { WaterCurrentDownParticle waterCurrentDownParticle = new WaterCurrentDownParticle(level, x, y, z); waterCurrentDownParticle.pickSprite(this.sprite); return waterCurrentDownParticle; } } }