RidingEntitySoundInstance.java
net.minecraft.client.resources.sounds.RidingEntitySoundInstance
信息
- 全限定名:net.minecraft.client.resources.sounds.RidingEntitySoundInstance
- 类型:public class
- 包:net.minecraft.client.resources.sounds
- 源码路径:src/main/java/net/minecraft/client/resources/sounds/RidingEntitySoundInstance.java
- 起始行号:L12
- 继承:AbstractTickableSoundInstance
- 职责:
TODO
字段/常量
-
player- 类型:
Player - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
entity- 类型:
Entity - 修饰符:
private final - 源码定位:
L14 - 说明:
TODO
- 类型:
-
underwaterSound- 类型:
boolean - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
-
volumeMin- 类型:
float - 修饰符:
private final - 源码定位:
L16 - 说明:
TODO
- 类型:
-
volumeMax- 类型:
float - 修饰符:
private final - 源码定位:
L17 - 说明:
TODO
- 类型:
-
volumeAmplifier- 类型:
float - 修饰符:
private final - 源码定位:
L18 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public RidingEntitySoundInstance(Player player, Entity entity, boolean underwaterSound, SoundEvent soundEvent, SoundSource soundSource, float volumeMin, float volumeMax, float volumeAmplifier) @ L20
- 构造器名:RidingEntitySoundInstance
- 源码定位:L20
- 修饰符:public
参数:
- player: Player
- entity: Entity
- underwaterSound: boolean
- soundEvent: SoundEvent
- soundSource: SoundSource
- volumeMin: float
- volumeMax: float
- volumeAmplifier: float
说明:
TODO
方法
下面的方法块按源码顺序生成。
public boolean canPlaySound() @ L43
- 方法名:canPlaySound
- 源码定位:L43
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean canStartSilent() @ L48
- 方法名:canStartSilent
- 源码定位:L48
- 返回类型:boolean
- 修饰符:public
参数:
- 无
说明:
TODO
protected boolean shouldNotPlayUnderwaterSound() @ L53
- 方法名:shouldNotPlayUnderwaterSound
- 源码定位:L53
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
protected float getEntitySpeed() @ L57
- 方法名:getEntitySpeed
- 源码定位:L57
- 返回类型:float
- 修饰符:protected
参数:
- 无
说明:
TODO
protected boolean shoudlPlaySound() @ L61
- 方法名:shoudlPlaySound
- 源码定位:L61
- 返回类型:boolean
- 修饰符:protected
参数:
- 无
说明:
TODO
public void tick() @ L65
- 方法名:tick
- 源码定位:L65
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class RidingEntitySoundInstance extends AbstractTickableSoundInstance {
private final Player player;
private final Entity entity;
private final boolean underwaterSound;
private final float volumeMin;
private final float volumeMax;
private final float volumeAmplifier;
public RidingEntitySoundInstance(
Player player,
Entity entity,
boolean underwaterSound,
SoundEvent soundEvent,
SoundSource soundSource,
float volumeMin,
float volumeMax,
float volumeAmplifier
) {
super(soundEvent, soundSource, SoundInstance.createUnseededRandom());
this.player = player;
this.entity = entity;
this.underwaterSound = underwaterSound;
this.volumeMin = volumeMin;
this.volumeMax = volumeMax;
this.volumeAmplifier = volumeAmplifier;
this.attenuation = SoundInstance.Attenuation.NONE;
this.looping = true;
this.delay = 0;
this.volume = volumeMin;
}
@Override
public boolean canPlaySound() {
return !this.entity.isSilent();
}
@Override
public boolean canStartSilent() {
return true;
}
protected boolean shouldNotPlayUnderwaterSound() {
return this.underwaterSound != this.entity.isUnderWater();
}
protected float getEntitySpeed() {
return (float)this.entity.getDeltaMovement().length();
}
protected boolean shoudlPlaySound() {
return true;
}
@Override
public void tick() {
if (this.entity.isRemoved() || !this.player.isPassenger() || this.player.getVehicle() != this.entity) {
this.stop();
} else if (this.shouldNotPlayUnderwaterSound()) {
this.volume = this.volumeMin;
} else {
float speed = this.getEntitySpeed();
if (speed >= 0.01F && this.shoudlPlaySound()) {
this.volume = this.volumeAmplifier * Mth.clampedLerp(speed, this.volumeMin, this.volumeMax);
} else {
this.volume = this.volumeMin;
}
}
}
}引用的其他类
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SoundInstance.createUnseededRandom()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clampedLerp()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置: