Music option
This commit is contained in:
parent
35ed6a05b1
commit
1d95a4c771
2 changed files with 43 additions and 30 deletions
|
@ -16,6 +16,7 @@ import net.minecraft.client.sound.SoundInstance;
|
|||
import net.minecraft.sound.MusicSound;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import ru.betterend.client.ClientOptions;
|
||||
|
||||
@Mixin(MusicTracker.class)
|
||||
public class MusicTrackerMixin {
|
||||
|
@ -39,42 +40,44 @@ public class MusicTrackerMixin {
|
|||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void beOnTick(CallbackInfo info) {
|
||||
MusicSound musicSound = client.getMusicType();
|
||||
if (volume > 0 && beIsInEnd() && beShouldChangeSound(musicSound)) {
|
||||
if (volume > 0) {
|
||||
if (srcVolume < 0) {
|
||||
srcVolume = current.getVolume();
|
||||
}
|
||||
if (current instanceof AbstractSoundInstance) {
|
||||
((AbstractSoundInstanceAccessor) current).setVolume(volume);
|
||||
}
|
||||
client.getSoundManager().updateSoundVolume(current.getCategory(), current.getVolume() * volume);
|
||||
long t = System.currentTimeMillis();
|
||||
if (volume == 1 && time == 0) {
|
||||
if (ClientOptions.blendBiomeMusic()) {
|
||||
MusicSound musicSound = client.getMusicType();
|
||||
if (volume > 0 && beIsInEnd() && beShouldChangeSound(musicSound)) {
|
||||
if (volume > 0) {
|
||||
if (srcVolume < 0) {
|
||||
srcVolume = current.getVolume();
|
||||
}
|
||||
if (current instanceof AbstractSoundInstance) {
|
||||
((AbstractSoundInstanceAccessor) current).setVolume(volume);
|
||||
}
|
||||
client.getSoundManager().updateSoundVolume(current.getCategory(), current.getVolume() * volume);
|
||||
long t = System.currentTimeMillis();
|
||||
if (volume == 1 && time == 0) {
|
||||
time = t;
|
||||
}
|
||||
float delta = (t - time) * 0.0005F;
|
||||
time = t;
|
||||
volume -= delta;
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
}
|
||||
}
|
||||
float delta = (t - time) * 0.0005F;
|
||||
time = t;
|
||||
volume -= delta;
|
||||
if (volume < 0) {
|
||||
volume = 0;
|
||||
if (volume == 0) {
|
||||
volume = 1;
|
||||
time = 0;
|
||||
srcVolume = -1;
|
||||
this.client.getSoundManager().stop(this.current);
|
||||
this.timeUntilNextSong = MathHelper.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
|
||||
this.current = null;
|
||||
}
|
||||
if (this.current == null && this.timeUntilNextSong-- <= 0) {
|
||||
this.play(musicSound);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
if (volume == 0) {
|
||||
else {
|
||||
volume = 1;
|
||||
time = 0;
|
||||
srcVolume = -1;
|
||||
this.client.getSoundManager().stop(this.current);
|
||||
this.timeUntilNextSong = MathHelper.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
|
||||
this.current = null;
|
||||
}
|
||||
if (this.current == null && this.timeUntilNextSong-- <= 0) {
|
||||
this.play(musicSound);
|
||||
}
|
||||
info.cancel();
|
||||
}
|
||||
else {
|
||||
volume = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue