Spaces:
Build error
Build error
File size: 2,140 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
package net.minecraft.client.resources.sounds;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class UnderwaterAmbientSoundInstances {
@OnlyIn(Dist.CLIENT)
public static class SubSound extends AbstractTickableSoundInstance {
private final LocalPlayer player;
protected SubSound(LocalPlayer p_119861_, SoundEvent p_119862_) {
super(p_119862_, SoundSource.AMBIENT, SoundInstance.createUnseededRandom());
this.player = p_119861_;
this.looping = false;
this.delay = 0;
this.volume = 1.0F;
this.relative = true;
}
@Override
public void tick() {
if (this.player.isRemoved() || !this.player.isUnderWater()) {
this.stop();
}
}
}
@OnlyIn(Dist.CLIENT)
public static class UnderwaterAmbientSoundInstance extends AbstractTickableSoundInstance {
public static final int FADE_DURATION = 40;
private final LocalPlayer player;
private int fade;
public UnderwaterAmbientSoundInstance(LocalPlayer p_119867_) {
super(SoundEvents.AMBIENT_UNDERWATER_LOOP, SoundSource.AMBIENT, SoundInstance.createUnseededRandom());
this.player = p_119867_;
this.looping = true;
this.delay = 0;
this.volume = 1.0F;
this.relative = true;
}
@Override
public void tick() {
if (!this.player.isRemoved() && this.fade >= 0) {
if (this.player.isUnderWater()) {
this.fade++;
} else {
this.fade -= 2;
}
this.fade = Math.min(this.fade, 40);
this.volume = Math.max(0.0F, Math.min((float)this.fade / 40.0F, 1.0F));
} else {
this.stop();
}
}
}
} |