Music option
This commit is contained in:
parent
35ed6a05b1
commit
1d95a4c771
2 changed files with 43 additions and 30 deletions
|
@ -5,10 +5,12 @@ import ru.betterend.config.Configs;
|
||||||
public class ClientOptions {
|
public class ClientOptions {
|
||||||
private static boolean customSky;
|
private static boolean customSky;
|
||||||
private static boolean useFogDensity;
|
private static boolean useFogDensity;
|
||||||
|
private static boolean blendBiomeMusic;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
setCustomSky(Configs.CLENT_CONFIG.getBooleanRoot("customSky", true));
|
setCustomSky(Configs.CLENT_CONFIG.getBooleanRoot("customSky", true));
|
||||||
setUseFogDensity(Configs.CLENT_CONFIG.getBooleanRoot("useFogDensity", true));
|
setUseFogDensity(Configs.CLENT_CONFIG.getBooleanRoot("useFogDensity", true));
|
||||||
|
setBlendBiomeMusic(Configs.CLENT_CONFIG.getBooleanRoot("blendBiomeMusic", true));
|
||||||
Configs.CLENT_CONFIG.saveChanges();
|
Configs.CLENT_CONFIG.saveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,4 +29,12 @@ public class ClientOptions {
|
||||||
public static void setUseFogDensity(boolean useFogDensity) {
|
public static void setUseFogDensity(boolean useFogDensity) {
|
||||||
ClientOptions.useFogDensity = useFogDensity;
|
ClientOptions.useFogDensity = useFogDensity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean blendBiomeMusic() {
|
||||||
|
return blendBiomeMusic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setBlendBiomeMusic(boolean blendBiomeMusic) {
|
||||||
|
ClientOptions.blendBiomeMusic = blendBiomeMusic;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.client.sound.SoundInstance;
|
||||||
import net.minecraft.sound.MusicSound;
|
import net.minecraft.sound.MusicSound;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import ru.betterend.client.ClientOptions;
|
||||||
|
|
||||||
@Mixin(MusicTracker.class)
|
@Mixin(MusicTracker.class)
|
||||||
public class MusicTrackerMixin {
|
public class MusicTrackerMixin {
|
||||||
|
@ -39,42 +40,44 @@ public class MusicTrackerMixin {
|
||||||
|
|
||||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||||
public void beOnTick(CallbackInfo info) {
|
public void beOnTick(CallbackInfo info) {
|
||||||
MusicSound musicSound = client.getMusicType();
|
if (ClientOptions.blendBiomeMusic()) {
|
||||||
if (volume > 0 && beIsInEnd() && beShouldChangeSound(musicSound)) {
|
MusicSound musicSound = client.getMusicType();
|
||||||
if (volume > 0) {
|
if (volume > 0 && beIsInEnd() && beShouldChangeSound(musicSound)) {
|
||||||
if (srcVolume < 0) {
|
if (volume > 0) {
|
||||||
srcVolume = current.getVolume();
|
if (srcVolume < 0) {
|
||||||
}
|
srcVolume = current.getVolume();
|
||||||
if (current instanceof AbstractSoundInstance) {
|
}
|
||||||
((AbstractSoundInstanceAccessor) current).setVolume(volume);
|
if (current instanceof AbstractSoundInstance) {
|
||||||
}
|
((AbstractSoundInstanceAccessor) current).setVolume(volume);
|
||||||
client.getSoundManager().updateSoundVolume(current.getCategory(), current.getVolume() * volume);
|
}
|
||||||
long t = System.currentTimeMillis();
|
client.getSoundManager().updateSoundVolume(current.getCategory(), current.getVolume() * volume);
|
||||||
if (volume == 1 && time == 0) {
|
long t = System.currentTimeMillis();
|
||||||
|
if (volume == 1 && time == 0) {
|
||||||
|
time = t;
|
||||||
|
}
|
||||||
|
float delta = (t - time) * 0.0005F;
|
||||||
time = t;
|
time = t;
|
||||||
|
volume -= delta;
|
||||||
|
if (volume < 0) {
|
||||||
|
volume = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
float delta = (t - time) * 0.0005F;
|
if (volume == 0) {
|
||||||
time = t;
|
volume = 1;
|
||||||
volume -= delta;
|
time = 0;
|
||||||
if (volume < 0) {
|
srcVolume = -1;
|
||||||
volume = 0;
|
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;
|
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