80 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
	
		
			2.7 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;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public class CampfireSmokeParticle extends TextureSheetParticle {
 | |
| 	CampfireSmokeParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, boolean signal) {
 | |
| 		super(level, x, y, z);
 | |
| 		this.scale(3.0F);
 | |
| 		this.setSize(0.25F, 0.25F);
 | |
| 		if (signal) {
 | |
| 			this.lifetime = this.random.nextInt(50) + 280;
 | |
| 		} else {
 | |
| 			this.lifetime = this.random.nextInt(50) + 80;
 | |
| 		}
 | |
| 
 | |
| 		this.gravity = 3.0E-6F;
 | |
| 		this.xd = xSpeed;
 | |
| 		this.yd = ySpeed + this.random.nextFloat() / 500.0F;
 | |
| 		this.zd = zSpeed;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void tick() {
 | |
| 		this.xo = this.x;
 | |
| 		this.yo = this.y;
 | |
| 		this.zo = this.z;
 | |
| 		if (this.age++ < this.lifetime && !(this.alpha <= 0.0F)) {
 | |
| 			this.xd = this.xd + this.random.nextFloat() / 5000.0F * (this.random.nextBoolean() ? 1 : -1);
 | |
| 			this.zd = this.zd + this.random.nextFloat() / 5000.0F * (this.random.nextBoolean() ? 1 : -1);
 | |
| 			this.yd = this.yd - this.gravity;
 | |
| 			this.move(this.xd, this.yd, this.zd);
 | |
| 			if (this.age >= this.lifetime - 60 && this.alpha > 0.01F) {
 | |
| 				this.alpha -= 0.015F;
 | |
| 			}
 | |
| 		} else {
 | |
| 			this.remove();
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public ParticleRenderType getRenderType() {
 | |
| 		return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class CosyProvider implements ParticleProvider<SimpleParticleType> {
 | |
| 		private final SpriteSet sprites;
 | |
| 
 | |
| 		public CosyProvider(SpriteSet sprites) {
 | |
| 			this.sprites = sprites;
 | |
| 		}
 | |
| 
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			CampfireSmokeParticle campfireSmokeParticle = new CampfireSmokeParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, false);
 | |
| 			campfireSmokeParticle.setAlpha(0.9F);
 | |
| 			campfireSmokeParticle.pickSprite(this.sprites);
 | |
| 			return campfireSmokeParticle;
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class SignalProvider implements ParticleProvider<SimpleParticleType> {
 | |
| 		private final SpriteSet sprites;
 | |
| 
 | |
| 		public SignalProvider(SpriteSet sprites) {
 | |
| 			this.sprites = sprites;
 | |
| 		}
 | |
| 
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			CampfireSmokeParticle campfireSmokeParticle = new CampfireSmokeParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, true);
 | |
| 			campfireSmokeParticle.setAlpha(0.95F);
 | |
| 			campfireSmokeParticle.pickSprite(this.sprites);
 | |
| 			return campfireSmokeParticle;
 | |
| 		}
 | |
| 	}
 | |
| }
 |