64 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
	
		
			2 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 HeartParticle extends TextureSheetParticle {
 | |
| 	HeartParticle(ClientLevel level, double x, double y, double z) {
 | |
| 		super(level, x, y, z, 0.0, 0.0, 0.0);
 | |
| 		this.speedUpWhenYMotionIsBlocked = true;
 | |
| 		this.friction = 0.86F;
 | |
| 		this.xd *= 0.01F;
 | |
| 		this.yd *= 0.01F;
 | |
| 		this.zd *= 0.01F;
 | |
| 		this.yd += 0.1;
 | |
| 		this.quadSize *= 1.5F;
 | |
| 		this.lifetime = 16;
 | |
| 		this.hasPhysics = false;
 | |
| 	}
 | |
| 
 | |
| 	@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);
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class AngryVillagerProvider implements ParticleProvider<SimpleParticleType> {
 | |
| 		private final SpriteSet sprite;
 | |
| 
 | |
| 		public AngryVillagerProvider(SpriteSet sprites) {
 | |
| 			this.sprite = sprites;
 | |
| 		}
 | |
| 
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			HeartParticle heartParticle = new HeartParticle(level, x, y + 0.5, z);
 | |
| 			heartParticle.pickSprite(this.sprite);
 | |
| 			heartParticle.setColor(1.0F, 1.0F, 1.0F);
 | |
| 			return heartParticle;
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@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) {
 | |
| 			HeartParticle heartParticle = new HeartParticle(level, x, y, z);
 | |
| 			heartParticle.pickSprite(this.sprite);
 | |
| 			return heartParticle;
 | |
| 		}
 | |
| 	}
 | |
| }
 |