ElytraOnPlayerSoundInstance.java
net.minecraft.client.resources.sounds.ElytraOnPlayerSoundInstance
信息
- 全限定名:net.minecraft.client.resources.sounds.ElytraOnPlayerSoundInstance
- 类型:public class
- 包:net.minecraft.client.resources.sounds
- 源码路径:src/main/java/net/minecraft/client/resources/sounds/ElytraOnPlayerSoundInstance.java
- 起始行号:L11
- 继承:AbstractTickableSoundInstance
- 职责:
TODO
字段/常量
-
DELAY- 类型:
int - 修饰符:
public static final - 源码定位:
L12 - 说明:
TODO
- 类型:
-
player- 类型:
LocalPlayer - 修饰符:
private final - 源码定位:
L13 - 说明:
TODO
- 类型:
-
time- 类型:
int - 修饰符:
private - 源码定位:
L14 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public ElytraOnPlayerSoundInstance(LocalPlayer player) @ L16
- 构造器名:ElytraOnPlayerSoundInstance
- 源码定位:L16
- 修饰符:public
参数:
- player: LocalPlayer
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void tick() @ L24
- 方法名:tick
- 源码定位:L24
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class ElytraOnPlayerSoundInstance extends AbstractTickableSoundInstance {
public static final int DELAY = 20;
private final LocalPlayer player;
private int time;
public ElytraOnPlayerSoundInstance(LocalPlayer player) {
super(SoundEvents.ELYTRA_FLYING, SoundSource.PLAYERS, SoundInstance.createUnseededRandom());
this.player = player;
this.looping = true;
this.delay = 0;
this.volume = 0.1F;
}
@Override
public void tick() {
this.time++;
if (!this.player.isRemoved() && (this.time <= 20 || this.player.isFallFlying())) {
this.x = (float)this.player.getX();
this.y = (float)this.player.getY();
this.z = (float)this.player.getZ();
float speed = (float)this.player.getDeltaMovement().lengthSqr();
if (speed >= 1.0E-7) {
this.volume = Mth.clamp(speed / 4.0F, 0.0F, 1.0F);
} else {
this.volume = 0.0F;
}
if (this.time < 20) {
this.volume = 0.0F;
} else if (this.time < 40) {
this.volume = this.volume * ((this.time - 20) / 20.0F);
}
float pitchThreshold = 0.8F;
if (this.volume > 0.8F) {
this.pitch = 1.0F + (this.volume - 0.8F);
} else {
this.pitch = 1.0F;
}
} else {
this.stop();
}
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SoundInstance.createUnseededRandom()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.clamp()
- 引用位置: