FallingDustParticle.java

net.minecraft.client.particle.FallingDustParticle

信息

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

    TODO

字段/常量

  • rotSpeed

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

      TODO

  • sprites

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

      TODO

内部类/嵌套类型

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

      TODO

构造器

private FallingDustParticle(ClientLevel level, double x, double y, double z, float r, float g, float b, SpriteSet sprites) @ L22

  • 构造器名:FallingDustParticle
  • 源码定位:L22
  • 修饰符:private

参数:

  • level: ClientLevel
  • x: double
  • y: double
  • z: double
  • r: float
  • g: float
  • b: float
  • 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 FallingDustParticle extends SingleQuadParticle {
    private final float rotSpeed;
    private final SpriteSet sprites;
 
    private FallingDustParticle(ClientLevel level, double x, double y, double z, float r, float g, float b, SpriteSet sprites) {
        super(level, x, y, z, sprites.first());
        this.sprites = sprites;
        this.rCol = r;
        this.gCol = g;
        this.bCol = b;
        float scale = 0.9F;
        this.quadSize *= 0.67499995F;
        int baseLifetime = (int)(32.0 / (this.random.nextFloat() * 0.8 + 0.2));
        this.lifetime = (int)Math.max(baseLifetime * 0.9F, 1.0F);
        this.setSpriteFromAge(sprites);
        this.rotSpeed = (this.random.nextFloat() - 0.5F) * 0.1F;
        this.roll = this.random.nextFloat() * (float) (Math.PI * 2);
    }
 
    @Override
    public SingleQuadParticle.Layer getLayer() {
        return SingleQuadParticle.Layer.OPAQUE;
    }
 
    @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() {
        this.xo = this.x;
        this.yo = this.y;
        this.zo = this.z;
        if (this.age++ >= this.lifetime) {
            this.remove();
        } else {
            this.setSpriteFromAge(this.sprites);
            this.oRoll = this.roll;
            this.roll = this.roll + (float) Math.PI * this.rotSpeed * 2.0F;
            if (this.onGround) {
                this.oRoll = this.roll = 0.0F;
            }
 
            this.move(this.xd, this.yd, this.zd);
            this.yd -= 0.003F;
            this.yd = Math.max(this.yd, -0.14F);
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Provider implements ParticleProvider<BlockParticleOption> {
        private final SpriteSet sprite;
 
        public Provider(SpriteSet sprite) {
            this.sprite = sprite;
        }
 
        public @Nullable Particle createParticle(
            BlockParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            BlockState blockState = options.getState();
            if (!blockState.isAir() && blockState.getRenderShape() == RenderShape.INVISIBLE) {
                return null;
            } else {
                BlockPos pos = BlockPos.containing(x, y, z);
                int tintColor;
                if (blockState.getBlock() instanceof FallingBlock fallingBlock) {
                    tintColor = fallingBlock.getDustColor(blockState, level, pos);
                } else {
                    BlockTintSource tintSource = Minecraft.getInstance().getBlockColors().getTintSource(blockState, 0);
                    if (tintSource != null) {
                        tintColor = tintSource.colorAsTerrainParticle(blockState, level, pos);
                    } else {
                        tintColor = blockState.getMapColor(level, pos).col;
                    }
                }
 
                float r = (tintColor >> 16 & 0xFF) / 255.0F;
                float g = (tintColor >> 8 & 0xFF) / 255.0F;
                float b = (tintColor & 0xFF) / 255.0F;
                return new FallingDustParticle(level, x, y, z, r, g, b, this.sprite);
            }
        }
    }
}

引用的其他类

  • Minecraft

    • 引用位置: 方法调用
    • 关联成员: Minecraft.getInstance()
  • ClientLevel

    • 引用位置: 参数
  • SingleQuadParticle

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

    • 引用位置: 参数/字段
  • BlockPos

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

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