PortalParticle.java

net.minecraft.client.particle.PortalParticle

信息

  • 全限定名:net.minecraft.client.particle.PortalParticle
  • 类型:public class
  • 包:net.minecraft.client.particle
  • 源码路径:src/main/java/net/minecraft/client/particle/PortalParticle.java
  • 起始行号:L12
  • 继承:SingleQuadParticle
  • 职责:

    TODO

字段/常量

  • xStart

    • 类型: double
    • 修饰符: private final
    • 源码定位: L13
    • 说明:

      TODO

  • yStart

    • 类型: double
    • 修饰符: private final
    • 源码定位: L14
    • 说明:

      TODO

  • zStart

    • 类型: double
    • 修饰符: private final
    • 源码定位: L15
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.particle.PortalParticle.Provider
    • 类型: class
    • 修饰符: public static
    • 源码定位: L82
    • 说明:

      TODO

构造器

protected PortalParticle(ClientLevel level, double x, double y, double z, double xd, double yd, double zd, TextureAtlasSprite sprite) @ L17

  • 构造器名:PortalParticle
  • 源码定位:L17
  • 修饰符:protected

参数:

  • level: ClientLevel
  • x: double
  • y: double
  • z: double
  • xd: double
  • yd: double
  • zd: double
  • sprite: TextureAtlasSprite

说明:

TODO

方法

下面的方法块按源码顺序生成。

public SingleQuadParticle.Layer getLayer() @ L36

  • 方法名:getLayer
  • 源码定位:L36
  • 返回类型:SingleQuadParticle.Layer
  • 修饰符:public

参数:

说明:

TODO

public void move(double xa, double ya, double za) @ L41

  • 方法名:move
  • 源码定位:L41
  • 返回类型:void
  • 修饰符:public

参数:

  • xa: double
  • ya: double
  • za: double

说明:

TODO

public float getQuadSize(float a) @ L47

  • 方法名:getQuadSize
  • 源码定位:L47
  • 返回类型:float
  • 修饰符:public

参数:

  • a: float

说明:

TODO

public int getLightCoords(float a) @ L56

  • 方法名:getLightCoords
  • 源码定位:L56
  • 返回类型:int
  • 修饰符:public

参数:

  • a: float

说明:

TODO

public void tick() @ L64

  • 方法名:tick
  • 源码定位:L64
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class PortalParticle extends SingleQuadParticle {
    private final double xStart;
    private final double yStart;
    private final double zStart;
 
    protected PortalParticle(ClientLevel level, double x, double y, double z, double xd, double yd, double zd, TextureAtlasSprite sprite) {
        super(level, x, y, z, sprite);
        this.xd = xd;
        this.yd = yd;
        this.zd = zd;
        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 br = this.random.nextFloat() * 0.6F + 0.4F;
        this.rCol = br * 0.9F;
        this.gCol = br * 0.3F;
        this.bCol = br;
        this.lifetime = (int)(this.random.nextFloat() * 10.0F) + 40;
    }
 
    @Override
    public SingleQuadParticle.Layer getLayer() {
        return SingleQuadParticle.Layer.OPAQUE;
    }
 
    @Override
    public void move(double xa, double ya, double za) {
        this.setBoundingBox(this.getBoundingBox().move(xa, ya, za));
        this.setLocationFromBoundingbox();
    }
 
    @Override
    public float getQuadSize(float a) {
        float s = (this.age + a) / this.lifetime;
        s = 1.0F - s;
        s *= s;
        s = 1.0F - s;
        return this.quadSize * s;
    }
 
    @Override
    public int getLightCoords(float a) {
        float brightness = (float)this.age / this.lifetime;
        brightness *= brightness;
        brightness *= brightness;
        return LightCoordsUtil.addSmoothBlockEmission(super.getLightCoords(a), brightness);
    }
 
    @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 pos = (float)this.age / this.lifetime;
            float var3 = -pos + pos * pos * 2.0F;
            float var4 = 1.0F - var3;
            this.x = this.xStart + this.xd * var4;
            this.y = this.yStart + this.yd * var4 + (1.0F - pos);
            this.z = this.zStart + this.zd * var4;
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Provider implements ParticleProvider<SimpleParticleType> {
        private final SpriteSet sprite;
 
        public Provider(SpriteSet sprite) {
            this.sprite = sprite;
        }
 
        public Particle createParticle(
            SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            return new PortalParticle(level, x, y, z, xAux, yAux, zAux, this.sprite.get(random));
        }
    }
}

引用的其他类