BreakingItemParticle.java

net.minecraft.client.particle.BreakingItemParticle

信息

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

    TODO

字段/常量

  • uo

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

      TODO

  • vo

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

      TODO

  • layer

    • 类型: SingleQuadParticle.Layer
    • 修饰符: private final
    • 源码定位: L23
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.particle.BreakingItemParticle.CobwebProvider

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

      TODO

  • net.minecraft.client.particle.BreakingItemParticle.ItemParticleProvider

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

      TODO

  • net.minecraft.client.particle.BreakingItemParticle.Provider

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

      TODO

  • net.minecraft.client.particle.BreakingItemParticle.SlimeProvider

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

      TODO

  • net.minecraft.client.particle.BreakingItemParticle.SnowballProvider

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

      TODO

构造器

private BreakingItemParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, TextureAtlasSprite sprite) @ L25

  • 构造器名:BreakingItemParticle
  • 源码定位:L25
  • 修饰符:private

参数:

  • level: ClientLevel
  • x: double
  • y: double
  • z: double
  • xa: double
  • ya: double
  • za: double
  • sprite: TextureAtlasSprite

说明:

TODO

protected BreakingItemParticle(ClientLevel level, double x, double y, double z, TextureAtlasSprite sprite) @ L35

  • 构造器名:BreakingItemParticle
  • 源码定位:L35
  • 修饰符:protected

参数:

  • level: ClientLevel
  • x: double
  • y: double
  • z: double
  • sprite: TextureAtlasSprite

说明:

TODO

方法

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

protected float getU0() @ L44

  • 方法名:getU0
  • 源码定位:L44
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getU1() @ L49

  • 方法名:getU1
  • 源码定位:L49
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getV0() @ L54

  • 方法名:getV0
  • 源码定位:L54
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

protected float getV1() @ L59

  • 方法名:getV1
  • 源码定位:L59
  • 返回类型:float
  • 修饰符:protected

参数:

说明:

TODO

public SingleQuadParticle.Layer getLayer() @ L64

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class BreakingItemParticle extends SingleQuadParticle {
    private final float uo;
    private final float vo;
    private final SingleQuadParticle.Layer layer;
 
    private BreakingItemParticle(ClientLevel level, double x, double y, double z, double xa, double ya, double za, TextureAtlasSprite sprite) {
        this(level, x, y, z, sprite);
        this.xd *= 0.1F;
        this.yd *= 0.1F;
        this.zd *= 0.1F;
        this.xd += xa;
        this.yd += ya;
        this.zd += za;
    }
 
    protected BreakingItemParticle(ClientLevel level, double x, double y, double z, TextureAtlasSprite sprite) {
        super(level, x, y, z, 0.0, 0.0, 0.0, sprite);
        this.gravity = 1.0F;
        this.quadSize /= 2.0F;
        this.uo = this.random.nextFloat() * 3.0F;
        this.vo = this.random.nextFloat() * 3.0F;
        this.layer = SingleQuadParticle.Layer.bySprite(sprite);
    }
 
    @Override
    protected float getU0() {
        return this.sprite.getU((this.uo + 1.0F) / 4.0F);
    }
 
    @Override
    protected float getU1() {
        return this.sprite.getU(this.uo / 4.0F);
    }
 
    @Override
    protected float getV0() {
        return this.sprite.getV(this.vo / 4.0F);
    }
 
    @Override
    protected float getV1() {
        return this.sprite.getV((this.vo + 1.0F) / 4.0F);
    }
 
    @Override
    public SingleQuadParticle.Layer getLayer() {
        return this.layer;
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class CobwebProvider extends BreakingItemParticle.ItemParticleProvider<SimpleParticleType> {
        public Particle createParticle(
            SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            return new BreakingItemParticle(level, x, y, z, this.getSprite(new ItemStackTemplate(Items.COBWEB), level, random));
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public abstract static class ItemParticleProvider<T extends ParticleOptions> implements ParticleProvider<T> {
        private final ItemStackRenderState scratchRenderState = new ItemStackRenderState();
 
        protected TextureAtlasSprite getSprite(ItemStackTemplate item, ClientLevel level, RandomSource random) {
            Minecraft.getInstance().getItemModelResolver().updateForTopItem(this.scratchRenderState, item.create(), ItemDisplayContext.GROUND, level, null, 0);
            Material.Baked material = this.scratchRenderState.pickParticleMaterial(random);
            return material != null ? material.sprite() : Minecraft.getInstance().getAtlasManager().getAtlasOrThrow(AtlasIds.ITEMS).missingSprite();
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Provider extends BreakingItemParticle.ItemParticleProvider<ItemParticleOption> {
        public Particle createParticle(
            ItemParticleOption options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            return new BreakingItemParticle(level, x, y, z, xAux, yAux, zAux, this.getSprite(options.getItem(), level, random));
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class SlimeProvider extends BreakingItemParticle.ItemParticleProvider<SimpleParticleType> {
        public Particle createParticle(
            SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            return new BreakingItemParticle(level, x, y, z, this.getSprite(new ItemStackTemplate(Items.SLIME_BALL), level, random));
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class SnowballProvider extends BreakingItemParticle.ItemParticleProvider<SimpleParticleType> {
        public Particle createParticle(
            SimpleParticleType options, ClientLevel level, double x, double y, double z, double xAux, double yAux, double zAux, RandomSource random
        ) {
            return new BreakingItemParticle(level, x, y, z, this.getSprite(new ItemStackTemplate(Items.SNOWBALL), level, random));
        }
    }
}

引用的其他类