46 lines
1.5 KiB
Java
46 lines
1.5 KiB
Java
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.particles.ScalableParticleOptionsBase;
|
|
import net.minecraft.util.Mth;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class DustParticleBase<T extends ScalableParticleOptionsBase> extends TextureSheetParticle {
|
|
private final SpriteSet sprites;
|
|
|
|
protected DustParticleBase(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, T options, SpriteSet sprites) {
|
|
super(level, x, y, z, xSpeed, ySpeed, zSpeed);
|
|
this.friction = 0.96F;
|
|
this.speedUpWhenYMotionIsBlocked = true;
|
|
this.sprites = sprites;
|
|
this.xd *= 0.1F;
|
|
this.yd *= 0.1F;
|
|
this.zd *= 0.1F;
|
|
this.quadSize = this.quadSize * (0.75F * options.getScale());
|
|
int i = (int)(8.0 / (this.random.nextDouble() * 0.8 + 0.2));
|
|
this.lifetime = (int)Math.max(i * options.getScale(), 1.0F);
|
|
this.setSpriteFromAge(sprites);
|
|
}
|
|
|
|
protected float randomizeColor(float coordMultiplier, float multiplier) {
|
|
return (this.random.nextFloat() * 0.2F + 0.8F) * coordMultiplier * multiplier;
|
|
}
|
|
|
|
@Override
|
|
public ParticleRenderType getRenderType() {
|
|
return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
|
|
}
|
|
|
|
@Override
|
|
public float getQuadSize(float scaleFactor) {
|
|
return this.quadSize * Mth.clamp((this.age + scaleFactor) / this.lifetime * 32.0F, 0.0F, 1.0F);
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
super.tick();
|
|
this.setSpriteFromAge(this.sprites);
|
|
}
|
|
}
|