95 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
	
		
			2.9 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.SimpleParticleType;
 | |
| import net.minecraft.util.Mth;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class CritParticle extends TextureSheetParticle {
 | |
| 	CritParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 		super(level, x, y, z, 0.0, 0.0, 0.0);
 | |
| 		this.friction = 0.7F;
 | |
| 		this.gravity = 0.5F;
 | |
| 		this.xd *= 0.1F;
 | |
| 		this.yd *= 0.1F;
 | |
| 		this.zd *= 0.1F;
 | |
| 		this.xd += xSpeed * 0.4;
 | |
| 		this.yd += ySpeed * 0.4;
 | |
| 		this.zd += zSpeed * 0.4;
 | |
| 		float f = (float)(Math.random() * 0.3F + 0.6F);
 | |
| 		this.rCol = f;
 | |
| 		this.gCol = f;
 | |
| 		this.bCol = f;
 | |
| 		this.quadSize *= 0.75F;
 | |
| 		this.lifetime = Math.max((int)(6.0 / (Math.random() * 0.8 + 0.6)), 1);
 | |
| 		this.hasPhysics = false;
 | |
| 		this.tick();
 | |
| 	}
 | |
| 
 | |
| 	@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.gCol *= 0.96F;
 | |
| 		this.bCol *= 0.9F;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public ParticleRenderType getRenderType() {
 | |
| 		return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class DamageIndicatorProvider implements ParticleProvider<SimpleParticleType> {
 | |
| 		private final SpriteSet sprite;
 | |
| 
 | |
| 		public DamageIndicatorProvider(SpriteSet sprites) {
 | |
| 			this.sprite = sprites;
 | |
| 		}
 | |
| 
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			CritParticle critParticle = new CritParticle(level, x, y, z, xSpeed, ySpeed + 1.0, zSpeed);
 | |
| 			critParticle.setLifetime(20);
 | |
| 			critParticle.pickSprite(this.sprite);
 | |
| 			return critParticle;
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class MagicProvider implements ParticleProvider<SimpleParticleType> {
 | |
| 		private final SpriteSet sprite;
 | |
| 
 | |
| 		public MagicProvider(SpriteSet sprites) {
 | |
| 			this.sprite = sprites;
 | |
| 		}
 | |
| 
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			CritParticle critParticle = new CritParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
 | |
| 			critParticle.rCol *= 0.3F;
 | |
| 			critParticle.gCol *= 0.8F;
 | |
| 			critParticle.pickSprite(this.sprite);
 | |
| 			return critParticle;
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class Provider implements ParticleProvider<SimpleParticleType> {
 | |
| 		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) {
 | |
| 			CritParticle critParticle = new CritParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
 | |
| 			critParticle.pickSprite(this.sprite);
 | |
| 			return critParticle;
 | |
| 		}
 | |
| 	}
 | |
| }
 |