AbstractSoundInstance.java

net.minecraft.client.resources.sounds.AbstractSoundInstance

信息

  • 全限定名:net.minecraft.client.resources.sounds.AbstractSoundInstance
  • 类型:public abstract class
  • 包:net.minecraft.client.resources.sounds
  • 源码路径:src/main/java/net/minecraft/client/resources/sounds/AbstractSoundInstance.java
  • 起始行号:L14
  • 实现:SoundInstance
  • 职责:

    TODO

字段/常量

  • sound

    • 类型: Sound
    • 修饰符: protected
    • 源码定位: L15
    • 说明:

      TODO

  • source

    • 类型: SoundSource
    • 修饰符: protected final
    • 源码定位: L16
    • 说明:

      TODO

  • identifier

    • 类型: Identifier
    • 修饰符: protected final
    • 源码定位: L17
    • 说明:

      TODO

  • volume

    • 类型: float
    • 修饰符: protected
    • 源码定位: L18
    • 说明:

      TODO

  • pitch

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

      TODO

  • x

    • 类型: double
    • 修饰符: protected
    • 源码定位: L20
    • 说明:

      TODO

  • y

    • 类型: double
    • 修饰符: protected
    • 源码定位: L21
    • 说明:

      TODO

  • z

    • 类型: double
    • 修饰符: protected
    • 源码定位: L22
    • 说明:

      TODO

  • looping

    • 类型: boolean
    • 修饰符: protected
    • 源码定位: L23
    • 说明:

      TODO

  • delay

    • 类型: int
    • 修饰符: protected
    • 源码定位: L24
    • 说明:

      TODO

  • attenuation

    • 类型: SoundInstance.Attenuation
    • 修饰符: protected
    • 源码定位: L25
    • 说明:

      TODO

  • relative

    • 类型: boolean
    • 修饰符: protected
    • 源码定位: L26
    • 说明:

      TODO

  • random

    • 类型: RandomSource
    • 修饰符: protected final
    • 源码定位: L27
    • 说明:

      TODO

内部类/嵌套类型

构造器

protected AbstractSoundInstance(SoundEvent event, SoundSource source, RandomSource random) @ L29

  • 构造器名:AbstractSoundInstance
  • 源码定位:L29
  • 修饰符:protected

参数:

  • event: SoundEvent
  • source: SoundSource
  • random: RandomSource

说明:

TODO

protected AbstractSoundInstance(Identifier identifier, SoundSource source, RandomSource random) @ L33

  • 构造器名:AbstractSoundInstance
  • 源码定位:L33
  • 修饰符:protected

参数:

  • identifier: Identifier
  • source: SoundSource
  • random: RandomSource

说明:

TODO

方法

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

public Identifier getIdentifier() @ L39

  • 方法名:getIdentifier
  • 源码定位:L39
  • 返回类型:Identifier
  • 修饰符:public

参数:

说明:

TODO

public WeighedSoundEvents resolve(SoundManager soundManager) @ L44

  • 方法名:resolve
  • 源码定位:L44
  • 返回类型:WeighedSoundEvents
  • 修饰符:public

参数:

  • soundManager: SoundManager

说明:

TODO

public Sound getSound() @ L61

  • 方法名:getSound
  • 源码定位:L61
  • 返回类型:Sound
  • 修饰符:public

参数:

说明:

TODO

public SoundSource getSource() @ L66

  • 方法名:getSource
  • 源码定位:L66
  • 返回类型:SoundSource
  • 修饰符:public

参数:

说明:

TODO

public boolean isLooping() @ L71

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

参数:

说明:

TODO

public int getDelay() @ L76

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

参数:

说明:

TODO

public float getVolume() @ L81

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

参数:

说明:

TODO

public float getPitch() @ L86

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

参数:

说明:

TODO

public double getX() @ L91

  • 方法名:getX
  • 源码定位:L91
  • 返回类型:double
  • 修饰符:public

参数:

说明:

TODO

public double getY() @ L96

  • 方法名:getY
  • 源码定位:L96
  • 返回类型:double
  • 修饰符:public

参数:

说明:

TODO

public double getZ() @ L101

  • 方法名:getZ
  • 源码定位:L101
  • 返回类型:double
  • 修饰符:public

参数:

说明:

TODO

public SoundInstance.Attenuation getAttenuation() @ L106

  • 方法名:getAttenuation
  • 源码定位:L106
  • 返回类型:SoundInstance.Attenuation
  • 修饰符:public

参数:

说明:

TODO

public boolean isRelative() @ L111

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

参数:

说明:

TODO

public String toString() @ L116

  • 方法名:toString
  • 源码定位:L116
  • 返回类型:String
  • 修饰符:public

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public abstract class AbstractSoundInstance implements SoundInstance {
    protected @Nullable Sound sound;
    protected final SoundSource source;
    protected final Identifier identifier;
    protected float volume = 1.0F;
    protected float pitch = 1.0F;
    protected double x;
    protected double y;
    protected double z;
    protected boolean looping;
    protected int delay;
    protected SoundInstance.Attenuation attenuation = SoundInstance.Attenuation.LINEAR;
    protected boolean relative;
    protected final RandomSource random;
 
    protected AbstractSoundInstance(SoundEvent event, SoundSource source, RandomSource random) {
        this(event.location(), source, random);
    }
 
    protected AbstractSoundInstance(Identifier identifier, SoundSource source, RandomSource random) {
        this.identifier = identifier;
        this.source = source;
        this.random = random;
    }
 
    @Override
    public Identifier getIdentifier() {
        return this.identifier;
    }
 
    @Override
    public @Nullable WeighedSoundEvents resolve(SoundManager soundManager) {
        if (this.identifier.equals(SoundManager.INTENTIONALLY_EMPTY_SOUND_LOCATION)) {
            this.sound = SoundManager.INTENTIONALLY_EMPTY_SOUND;
            return SoundManager.INTENTIONALLY_EMPTY_SOUND_EVENT;
        } else {
            WeighedSoundEvents soundEvent = soundManager.getSoundEvent(this.identifier);
            if (soundEvent == null) {
                this.sound = SoundManager.EMPTY_SOUND;
            } else {
                this.sound = soundEvent.getSound(this.random);
            }
 
            return soundEvent;
        }
    }
 
    @Override
    public @Nullable Sound getSound() {
        return this.sound;
    }
 
    @Override
    public SoundSource getSource() {
        return this.source;
    }
 
    @Override
    public boolean isLooping() {
        return this.looping;
    }
 
    @Override
    public int getDelay() {
        return this.delay;
    }
 
    @Override
    public float getVolume() {
        return this.volume * this.sound.getVolume().sample(this.random);
    }
 
    @Override
    public float getPitch() {
        return this.pitch * this.sound.getPitch().sample(this.random);
    }
 
    @Override
    public double getX() {
        return this.x;
    }
 
    @Override
    public double getY() {
        return this.y;
    }
 
    @Override
    public double getZ() {
        return this.z;
    }
 
    @Override
    public SoundInstance.Attenuation getAttenuation() {
        return this.attenuation;
    }
 
    @Override
    public boolean isRelative() {
        return this.relative;
    }
 
    @Override
    public String toString() {
        return "SoundInstance[" + this.identifier + "]";
    }
}

引用的其他类