100 lines
		
	
	
	
		
			2.6 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			100 lines
		
	
	
	
		
			2.6 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 PortalParticle extends TextureSheetParticle {
 | |
| 	private final double xStart;
 | |
| 	private final double yStart;
 | |
| 	private final double zStart;
 | |
| 
 | |
| 	protected PortalParticle(ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 		super(level, x, y, z);
 | |
| 		this.xd = xSpeed;
 | |
| 		this.yd = ySpeed;
 | |
| 		this.zd = zSpeed;
 | |
| 		this.x = x;
 | |
| 		this.y = y;
 | |
| 		this.z = z;
 | |
| 		this.xStart = this.x;
 | |
| 		this.yStart = this.y;
 | |
| 		this.zStart = this.z;
 | |
| 		this.quadSize = 0.1F * (this.random.nextFloat() * 0.2F + 0.5F);
 | |
| 		float f = this.random.nextFloat() * 0.6F + 0.4F;
 | |
| 		this.rCol = f * 0.9F;
 | |
| 		this.gCol = f * 0.3F;
 | |
| 		this.bCol = f;
 | |
| 		this.lifetime = (int)(Math.random() * 10.0) + 40;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public ParticleRenderType getRenderType() {
 | |
| 		return ParticleRenderType.PARTICLE_SHEET_OPAQUE;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void move(double x, double y, double z) {
 | |
| 		this.setBoundingBox(this.getBoundingBox().move(x, y, z));
 | |
| 		this.setLocationFromBoundingbox();
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public float getQuadSize(float scaleFactor) {
 | |
| 		float f = (this.age + scaleFactor) / this.lifetime;
 | |
| 		f = 1.0F - f;
 | |
| 		f *= f;
 | |
| 		f = 1.0F - f;
 | |
| 		return this.quadSize * f;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public int getLightColor(float partialTick) {
 | |
| 		int i = super.getLightColor(partialTick);
 | |
| 		float f = (float)this.age / this.lifetime;
 | |
| 		f *= f;
 | |
| 		f *= f;
 | |
| 		int j = i & 0xFF;
 | |
| 		int k = i >> 16 & 0xFF;
 | |
| 		k += (int)(f * 15.0F * 16.0F);
 | |
| 		if (k > 240) {
 | |
| 			k = 240;
 | |
| 		}
 | |
| 
 | |
| 		return j | k << 16;
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	public void tick() {
 | |
| 		this.xo = this.x;
 | |
| 		this.yo = this.y;
 | |
| 		this.zo = this.z;
 | |
| 		if (this.age++ >= this.lifetime) {
 | |
| 			this.remove();
 | |
| 		} else {
 | |
| 			float f = (float)this.age / this.lifetime;
 | |
| 			float var3 = -f + f * f * 2.0F;
 | |
| 			float var4 = 1.0F - var3;
 | |
| 			this.x = this.xStart + this.xd * var4;
 | |
| 			this.y = this.yStart + this.yd * var4 + (1.0F - f);
 | |
| 			this.z = this.zStart + this.zd * var4;
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class Provider implements ParticleProvider<SimpleParticleType> {
 | |
| 		private final SpriteSet sprite;
 | |
| 
 | |
| 		public Provider(SpriteSet sprite) {
 | |
| 			this.sprite = sprite;
 | |
| 		}
 | |
| 
 | |
| 		public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
 | |
| 			PortalParticle portalParticle = new PortalParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
 | |
| 			portalParticle.pickSprite(this.sprite);
 | |
| 			return portalParticle;
 | |
| 		}
 | |
| 	}
 | |
| }
 |