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

77 lines
2.7 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.Direction;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.util.RandomSource;
public class WaterDropParticle
extends SingleQuadParticle {
protected WaterDropParticle(ClientLevel level, double x, double y, double z, TextureAtlasSprite sprite) {
super(level, x, y, z, 0.0, 0.0, 0.0, sprite);
this.xd *= (double)0.3f;
this.yd = Math.random() * (double)0.2f + (double)0.1f;
this.zd *= (double)0.3f;
this.setSize(0.01f, 0.01f);
this.gravity = 0.06f;
this.lifetime = (int)(8.0 / (Math.random() * 0.8 + 0.2));
}
@Override
public SingleQuadParticle.Layer getLayer() {
return SingleQuadParticle.Layer.OPAQUE;
}
@Override
public void tick() {
BlockPos pos;
double offset;
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.lifetime-- <= 0) {
this.remove();
return;
}
this.yd -= (double)this.gravity;
this.move(this.xd, this.yd, this.zd);
this.xd *= (double)0.98f;
this.yd *= (double)0.98f;
this.zd *= (double)0.98f;
if (this.onGround) {
if (Math.random() < 0.5) {
this.remove();
}
this.xd *= (double)0.7f;
this.zd *= (double)0.7f;
}
if ((offset = Math.max(this.level.getBlockState(pos = BlockPos.containing(this.x, this.y, this.z)).getCollisionShape(this.level, pos).max(Direction.Axis.Y, this.x - (double)pos.getX(), this.z - (double)pos.getZ()), (double)this.level.getFluidState(pos).getHeight(this.level, pos))) > 0.0 && this.y < (double)pos.getY() + offset) {
this.remove();
}
}
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) {
return new WaterDropParticle(level, x, y, z, this.sprite.get(random));
}
}
}