EntityBoundSoundInstance.java

net.minecraft.client.resources.sounds.EntityBoundSoundInstance

信息

  • 全限定名:net.minecraft.client.resources.sounds.EntityBoundSoundInstance
  • 类型:public class
  • 包:net.minecraft.client.resources.sounds
  • 源码路径:src/main/java/net/minecraft/client/resources/sounds/EntityBoundSoundInstance.java
  • 起始行号:L11
  • 继承:AbstractTickableSoundInstance
  • 职责:

    TODO

字段/常量

  • entity
    • 类型: Entity
    • 修饰符: private final
    • 源码定位: L12
    • 说明:

      TODO

内部类/嵌套类型

构造器

public EntityBoundSoundInstance(SoundEvent event, SoundSource source, float volume, float pitch, Entity entity, long seed) @ L14

  • 构造器名:EntityBoundSoundInstance
  • 源码定位:L14
  • 修饰符:public

参数:

  • event: SoundEvent
  • source: SoundSource
  • volume: float
  • pitch: float
  • entity: Entity
  • seed: long

说明:

TODO

方法

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

public boolean canPlaySound() @ L24

  • 方法名:canPlaySound
  • 源码定位:L24
  • 返回类型:boolean
  • 修饰符:public

参数:

说明:

TODO

public void tick() @ L29

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class EntityBoundSoundInstance extends AbstractTickableSoundInstance {
    private final Entity entity;
 
    public EntityBoundSoundInstance(SoundEvent event, SoundSource source, float volume, float pitch, Entity entity, long seed) {
        super(event, source, RandomSource.create(seed));
        this.volume = volume;
        this.pitch = pitch;
        this.entity = entity;
        this.x = (float)this.entity.getX();
        this.y = (float)this.entity.getY();
        this.z = (float)this.entity.getZ();
    }
 
    @Override
    public boolean canPlaySound() {
        return !this.entity.isSilent();
    }
 
    @Override
    public void tick() {
        if (this.entity.isRemoved()) {
            this.stop();
        } else {
            this.x = (float)this.entity.getX();
            this.y = (float)this.entity.getY();
            this.z = (float)this.entity.getZ();
        }
    }
}

引用的其他类