Migration complete

This commit is contained in:
Aleksey 2021-04-17 00:26:35 +03:00
parent 2a8853d615
commit 81edbacc12
25 changed files with 173 additions and 172 deletions

View file

@ -17,20 +17,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.betterend.client.ClientOptions;
@Mixin(MusicManager.class)
public class MusicTrackerMixin {
@Shadow
public abstract class MusicTrackerMixin {
@Final
private Minecraft client;
@Shadow
private Minecraft minecraft;
@Final
@Shadow
private Random random;
@Shadow
private SoundInstance current;
private SoundInstance currentMusic;
@Shadow
private int timeUntilNextSong;
private int nextSongDelay;
private static float volume = 1;
private static float srcVolume = 0;
@ -39,16 +39,16 @@ public class MusicTrackerMixin {
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
public void be_onTick(CallbackInfo info) {
if (ClientOptions.blendBiomeMusic()) {
Music musicSound = client.getSituationalMusic();
Music musicSound = minecraft.getSituationalMusic();
if (be_checkNullSound(musicSound) && volume > 0 && be_isInEnd() && be_shouldChangeSound(musicSound)) {
if (volume > 0) {
if (srcVolume < 0) {
srcVolume = current.getVolume();
srcVolume = currentMusic.getVolume();
}
if (current instanceof AbstractSoundInstance) {
((AbstractSoundInstanceAccessor) current).setVolume(volume);
if (currentMusic instanceof AbstractSoundInstance) {
((AbstractSoundInstanceAccessor) currentMusic).setVolume(volume);
}
client.getSoundManager().updateSourceVolume(current.getSource(), current.getVolume() * volume);
minecraft.getSoundManager().updateSourceVolume(currentMusic.getSource(), currentMusic.getVolume() * volume);
long t = System.currentTimeMillis();
if (volume == 1 && time == 0) {
time = t;
@ -64,12 +64,12 @@ public class MusicTrackerMixin {
volume = 1;
time = 0;
srcVolume = -1;
this.client.getSoundManager().stop(this.current);
this.timeUntilNextSong = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
this.current = null;
this.minecraft.getSoundManager().stop(this.currentMusic);
this.nextSongDelay = Mth.nextInt(this.random, 0, musicSound.getMinDelay() / 2);
this.currentMusic = null;
}
if (this.current == null && this.timeUntilNextSong-- <= 0) {
this.play(musicSound);
if (this.currentMusic == null && this.nextSongDelay-- <= 0) {
this.startPlaying(musicSound);
}
info.cancel();
}
@ -80,11 +80,11 @@ public class MusicTrackerMixin {
}
private boolean be_isInEnd() {
return client.level != null && client.level.dimension().equals(Level.END);
return minecraft.level != null && minecraft.level.dimension().equals(Level.END);
}
private boolean be_shouldChangeSound(Music musicSound) {
return current != null && !musicSound.getEvent().getLocation().equals(this.current.getLocation()) && musicSound.replaceCurrentMusic();
return currentMusic != null && !musicSound.getEvent().getLocation().equals(this.currentMusic.getLocation()) && musicSound.replaceCurrentMusic();
}
private boolean be_checkNullSound(Music musicSound) {
@ -92,5 +92,5 @@ public class MusicTrackerMixin {
}
@Shadow
public void play(Music type) {}
public abstract void startPlaying(Music type);
}