FlyStraightTowardsParticle.java

net.minecraft.client.particle.FlyStraightTowardsParticle

信息

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

    TODO

字段/常量

  • xStart

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

      TODO

  • yStart

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

      TODO

  • zStart

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

      TODO

  • startColor

    • 类型: int
    • 修饰符: private final
    • 源码定位: L18
    • 说明:

      TODO

  • endColor

    • 类型: int
    • 修饰符: private final
    • 源码定位: L19
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.particle.FlyStraightTowardsParticle.OminousSpawnProvider
    • 类型: class
    • 修饰符: public static
    • 源码定位: L78
    • 说明:

      TODO

构造器

private FlyStraightTowardsParticle(ClientLevel level, double x, double y, double z, double xd, double yd, double zd, int startColor, int endColor, TextureAtlasSprite sprite) @ L21

  • 构造器名:FlyStraightTowardsParticle
  • 源码定位:L21
  • 修饰符:private

参数:

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

说明:

TODO

方法

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

public SingleQuadParticle.Layer getLayer() @ L44

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

参数:

说明:

TODO

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

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

参数:

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

说明:

TODO

public int getLightCoords(float a) @ L53

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

参数:

  • a: float

说明:

TODO

public void tick() @ L58

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class FlyStraightTowardsParticle extends SingleQuadParticle {
    private final double xStart;
    private final double yStart;
    private final double zStart;
    private final int startColor;
    private final int endColor;
 
    private FlyStraightTowardsParticle(
        ClientLevel level, double x, double y, double z, double xd, double yd, double zd, int startColor, int endColor, TextureAtlasSprite sprite
    ) {
        super(level, x, y, z, sprite);
        this.xd = xd;
        this.yd = yd;
        this.zd = zd;
        this.xStart = x;
        this.yStart = y;
        this.zStart = z;
        this.xo = x + xd;
        this.yo = y + yd;
        this.zo = z + zd;
        this.x = this.xo;
        this.y = this.yo;
        this.z = this.zo;
        this.quadSize = 0.1F * (this.random.nextFloat() * 0.5F + 0.2F);
        this.hasPhysics = false;
        this.lifetime = (int)(this.random.nextFloat() * 5.0F) + 25;
        this.startColor = startColor;
        this.endColor = endColor;
    }
 
    @Override
    public SingleQuadParticle.Layer getLayer() {
        return SingleQuadParticle.Layer.OPAQUE;
    }
 
    @Override
    public void move(double xa, double ya, double za) {
    }
 
    @Override
    public int getLightCoords(float a) {
        return LightCoordsUtil.withBlock(super.getLightCoords(a), 15);
    }
 
    @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 normalizedAge = (float)this.age / this.lifetime;
            float posAlpha = 1.0F - normalizedAge;
            this.x = this.xStart + this.xd * posAlpha;
            this.y = this.yStart + this.yd * posAlpha;
            this.z = this.zStart + this.zd * posAlpha;
            int color = ARGB.srgbLerp(normalizedAge, this.startColor, this.endColor);
            this.setColor(ARGB.red(color) / 255.0F, ARGB.green(color) / 255.0F, ARGB.blue(color) / 255.0F);
            this.setAlpha(ARGB.alpha(color) / 255.0F);
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class OminousSpawnProvider implements ParticleProvider<SimpleParticleType> {
        private final SpriteSet sprite;
 
        public OminousSpawnProvider(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
        ) {
            FlyStraightTowardsParticle particle = new FlyStraightTowardsParticle(level, x, y, z, xAux, yAux, zAux, -12210434, -1, this.sprite.get(random));
            particle.scale(Mth.randomBetween(level.getRandom(), 3.0F, 5.0F));
            return particle;
        }
    }
}

引用的其他类

  • ClientLevel

    • 引用位置: 参数
  • SingleQuadParticle

    • 引用位置: 继承/返回值
  • TextureAtlasSprite

    • 引用位置: 参数
  • ARGB

    • 引用位置: 方法调用
    • 关联成员: ARGB.alpha(), ARGB.blue(), ARGB.green(), ARGB.red(), ARGB.srgbLerp()
  • LightCoordsUtil

    • 引用位置: 方法调用
    • 关联成员: LightCoordsUtil.withBlock()
  • Mth

    • 引用位置: 方法调用
    • 关联成员: Mth.randomBetween()