minecraft-src/net/minecraft/client/particle/ReversePortalParticle.java
2025-07-04 03:15:13 +03:00

51 lines
1.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 ReversePortalParticle extends PortalParticle {
ReversePortalParticle(ClientLevel clientLevel, double d, double e, double f, double g, double h, double i) {
super(clientLevel, d, e, f, g, h, i);
this.quadSize *= 1.5F;
this.lifetime = (int)(Math.random() * 2.0) + 60;
}
@Override
public float getQuadSize(float scaleFactor) {
float f = 1.0F - (this.age + scaleFactor) / (this.lifetime * 1.5F);
return this.quadSize * f;
}
@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;
this.x = this.x + this.xd * f;
this.y = this.y + this.yd * f;
this.z = this.z + this.zd * f;
}
}
@Environment(EnvType.CLIENT)
public static class ReversePortalProvider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet sprite;
public ReversePortalProvider(SpriteSet sprites) {
this.sprite = sprites;
}
public Particle createParticle(SimpleParticleType type, ClientLevel level, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
ReversePortalParticle reversePortalParticle = new ReversePortalParticle(level, x, y, z, xSpeed, ySpeed, zSpeed);
reversePortalParticle.pickSprite(this.sprite);
return reversePortalParticle;
}
}
}