BeeSoundInstance.java
net.minecraft.client.resources.sounds.BeeSoundInstance
信息
- 全限定名:net.minecraft.client.resources.sounds.BeeSoundInstance
- 类型:public abstract class
- 包:net.minecraft.client.resources.sounds
- 源码路径:src/main/java/net/minecraft/client/resources/sounds/BeeSoundInstance.java
- 起始行号:L12
- 继承:AbstractTickableSoundInstance
- 职责:
TODO
字段/常量
-
VOLUME_MIN- 类型:
float - 修饰符:
private static final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
VOLUME_MAX- 类型:
float - 修饰符:
private static final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
PITCH_MIN- 类型:
float - 修饰符:
private static final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
bee- 类型:
Bee - 修饰符:
protected final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
hasSwitched- 类型:
boolean - 修饰符:
private - 源码定位:
L17 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public BeeSoundInstance(Bee bee, SoundEvent event, SoundSource source) @ L19
- 构造器名:BeeSoundInstance
- 源码定位:L19
- 修饰符:public
参数:
- bee: Bee
- event: SoundEvent
- source: SoundSource
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void tick() @ L30
- 方法名:tick
- 源码定位:L30
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
private float getMinPitch() @ L55
- 方法名:getMinPitch
- 源码定位:L55
- 返回类型:float
- 修饰符:private
参数:
- 无
说明:
TODO
private float getMaxPitch() @ L59
- 方法名:getMaxPitch
- 源码定位:L59
- 返回类型:float
- 修饰符:private
参数:
- 无
说明:
TODO
public boolean canStartSilent() @ L63
- 方法名:canStartSilent
- 源码定位:L63
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean canPlaySound() @ L68
- 方法名:canPlaySound
- 源码定位:L68
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
protected abstract AbstractTickableSoundInstance getAlternativeSoundInstance() @ L73
- 方法名:getAlternativeSoundInstance
- 源码定位:L73
- 返回类型:AbstractTickableSoundInstance
- 修饰符:protected abstract
参数:
- 无
说明:
TODO
protected abstract boolean shouldSwitchSounds() @ L75
- 方法名:shouldSwitchSounds
- 源码定位:L75
- 返回类型:boolean
- 修饰符:protected abstract
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public abstract class BeeSoundInstance extends AbstractTickableSoundInstance {
private static final float VOLUME_MIN = 0.0F;
private static final float VOLUME_MAX = 1.2F;
private static final float PITCH_MIN = 0.0F;
protected final Bee bee;
private boolean hasSwitched;
public BeeSoundInstance(Bee bee, SoundEvent event, SoundSource source) {
super(event, source, SoundInstance.createUnseededRandom());
this.bee = bee;
this.x = (float)bee.getX();
this.y = (float)bee.getY();
this.z = (float)bee.getZ();
this.looping = true;
this.delay = 0;
this.volume = 0.0F;
}
@Override
public void tick() {
boolean shouldSwitchSounds = this.shouldSwitchSounds();
if (shouldSwitchSounds && !this.isStopped()) {
Minecraft.getInstance().getSoundManager().queueTickingSound(this.getAlternativeSoundInstance());
this.hasSwitched = true;
}
if (!this.bee.isRemoved() && !this.hasSwitched) {
this.x = (float)this.bee.getX();
this.y = (float)this.bee.getY();
this.z = (float)this.bee.getZ();
float speed = (float)this.bee.getDeltaMovement().horizontalDistance();
if (speed >= 0.01F) {
this.pitch = Mth.lerp(Mth.clamp(speed, this.getMinPitch(), this.getMaxPitch()), this.getMinPitch(), this.getMaxPitch());
this.volume = Mth.lerp(Mth.clamp(speed, 0.0F, 0.5F), 0.0F, 1.2F);
} else {
this.pitch = 0.0F;
this.volume = 0.0F;
}
} else {
this.stop();
}
}
private float getMinPitch() {
return this.bee.isBaby() ? 1.1F : 0.7F;
}
private float getMaxPitch() {
return this.bee.isBaby() ? 1.5F : 1.1F;
}
@Override
public boolean canStartSilent() {
return true;
}
@Override
public boolean canPlaySound() {
return !this.bee.isSilent();
}
protected abstract AbstractTickableSoundInstance getAlternativeSoundInstance();
protected abstract boolean shouldSwitchSounds();
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
继承/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SoundInstance.createUnseededRandom()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clamp(), Mth.lerp()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置: