PlayerCloudParticle.java

net.minecraft.client.particle.PlayerCloudParticle

信息

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

    TODO

字段/常量

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

      TODO

内部类/嵌套类型

  • net.minecraft.client.particle.PlayerCloudParticle.Provider

    • 类型: class
    • 修饰符: public static
    • 源码定位: L65
    • 说明:

      TODO

  • net.minecraft.client.particle.PlayerCloudParticle.SneezeProvider

    • 类型: class
    • 修饰符: public static
    • 源码定位: L80
    • 说明:

      TODO

构造器

private PlayerCloudParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, SpriteSet sprites) @ L15

  • 构造器名:PlayerCloudParticle
  • 源码定位:L15
  • 修饰符:private

参数:

  • level: ClientLevel
  • x: double
  • y: double
  • z: double
  • xa: double
  • ya: double
  • za: double
  • sprites: SpriteSet

说明:

TODO

方法

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

public SingleQuadParticle.Layer getLayer() @ L37

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

参数:

说明:

TODO

public float getQuadSize(float a) @ L42

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

参数:

  • a: float

说明:

TODO

public void tick() @ L47

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class PlayerCloudParticle extends SingleQuadParticle {
    private final SpriteSet sprites;
 
    private PlayerCloudParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, SpriteSet sprites) {
        super(level, x, y, z, 0.0, 0.0, 0.0, sprites.first());
        this.friction = 0.96F;
        this.sprites = sprites;
        float scale = 2.5F;
        this.xd *= 0.1F;
        this.yd *= 0.1F;
        this.zd *= 0.1F;
        this.xd += xa;
        this.yd += ya;
        this.zd += za;
        float col = 1.0F - this.random.nextFloat() * 0.3F;
        this.rCol = col;
        this.gCol = col;
        this.bCol = col;
        this.quadSize *= 1.875F;
        int baseLifetime = (int)(8.0 / (this.random.nextFloat() * 0.8 + 0.3));
        this.lifetime = (int)Math.max(baseLifetime * 2.5F, 1.0F);
        this.hasPhysics = false;
        this.setSpriteFromAge(sprites);
    }
 
    @Override
    public SingleQuadParticle.Layer getLayer() {
        return SingleQuadParticle.Layer.TRANSLUCENT;
    }
 
    @Override
    public float getQuadSize(float a) {
        return this.quadSize * Mth.clamp((this.age + a) / this.lifetime * 32.0F, 0.0F, 1.0F);
    }
 
    @Override
    public void tick() {
        super.tick();
        if (!this.removed) {
            this.setSpriteFromAge(this.sprites);
            Player player = this.level.getNearestPlayer(this.x, this.y, this.z, 2.0, false);
            if (player != null) {
                double playerY = player.getY();
                if (this.y > playerY) {
                    this.y = this.y + (playerY - this.y) * 0.2;
                    this.yd = this.yd + (player.getDeltaMovement().y - this.yd) * 0.2;
                    this.setPos(this.x, this.y, this.z);
                }
            }
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Provider implements ParticleProvider<SimpleParticleType> {
        private final SpriteSet sprites;
 
        public Provider(SpriteSet sprites) {
            this.sprites = sprites;
        }
 
        public Particle createParticle(
            SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            return new PlayerCloudParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class SneezeProvider implements ParticleProvider<SimpleParticleType> {
        private final SpriteSet sprites;
 
        public SneezeProvider(SpriteSet sprites) {
            this.sprites = sprites;
        }
 
        public Particle createParticle(
            SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            PlayerCloudParticle particle = new PlayerCloudParticle(level, x, y, z, xAux, yAux, zAux, this.sprites);
            particle.setColor(0.22F, 1.0F, 0.53F);
            particle.setAlpha(0.4F);
            return particle;
        }
    }
}

引用的其他类