Continue mapping migration
This commit is contained in:
parent
99ade39404
commit
f03fd03bd0
499 changed files with 12567 additions and 12723 deletions
|
@ -1,47 +1,45 @@
|
|||
package ru.betterend.mixin.client;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.sounds.AbstractSoundInstance;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.MusicManager;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.sound.AbstractSoundInstance;
|
||||
import net.minecraft.client.sound.MusicTracker;
|
||||
import net.minecraft.client.sound.SoundInstance;
|
||||
import net.minecraft.sound.MusicSound;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.Level;
|
||||
import ru.betterend.client.ClientOptions;
|
||||
|
||||
@Mixin(MusicTracker.class)
|
||||
@Mixin(MusicManager.class)
|
||||
public class MusicTrackerMixin {
|
||||
@Shadow
|
||||
@Final
|
||||
private Minecraft client;
|
||||
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Random random;
|
||||
|
||||
|
||||
@Shadow
|
||||
private SoundInstance current;
|
||||
|
||||
|
||||
@Shadow
|
||||
private int timeUntilNextSong;
|
||||
|
||||
|
||||
private static float volume = 1;
|
||||
private static float srcVolume = 0;
|
||||
private static long time;
|
||||
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void be_onTick(CallbackInfo info) {
|
||||
if (ClientOptions.blendBiomeMusic()) {
|
||||
MusicSound musicSound = client.getMusicType();
|
||||
Music musicSound = client.getSituationalMusic();
|
||||
if (be_checkNullSound(musicSound) && volume > 0 && be_isInEnd() && be_shouldChangeSound(musicSound)) {
|
||||
if (volume > 0) {
|
||||
if (srcVolume < 0) {
|
||||
|
@ -50,7 +48,7 @@ public class MusicTrackerMixin {
|
|||
if (current instanceof AbstractSoundInstance) {
|
||||
((AbstractSoundInstanceAccessor) current).setVolume(volume);
|
||||
}
|
||||
client.getSoundManager().updateSoundVolume(current.getCategory(), current.getVolume() * volume);
|
||||
client.getSoundManager().updateSourceVolume(current.getSource(), current.getVolume() * volume);
|
||||
long t = System.currentTimeMillis();
|
||||
if (volume == 1 && time == 0) {
|
||||
time = t;
|
||||
|
@ -74,26 +72,25 @@ public class MusicTrackerMixin {
|
|||
this.play(musicSound);
|
||||
}
|
||||
info.cancel();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
volume = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean be_isInEnd() {
|
||||
return client.world != null && client.world.dimension().equals(Level.END);
|
||||
return client.level != null && client.level.dimension().equals(Level.END);
|
||||
}
|
||||
|
||||
private boolean be_shouldChangeSound(MusicSound musicSound) {
|
||||
return current != null && !musicSound.getSound().getId().equals(this.current.getId())
|
||||
&& musicSound.shouldReplaceCurrentMusic();
|
||||
|
||||
private boolean be_shouldChangeSound(Music musicSound) {
|
||||
return current != null && !musicSound.getEvent().getLocation().equals(this.current.getLocation()) && musicSound.replaceCurrentMusic();
|
||||
}
|
||||
|
||||
private boolean be_checkNullSound(MusicSound musicSound) {
|
||||
return musicSound != null && musicSound.getSound() != null;
|
||||
|
||||
private boolean be_checkNullSound(Music musicSound) {
|
||||
return musicSound != null && musicSound.getEvent() != null;
|
||||
}
|
||||
|
||||
|
||||
@Shadow
|
||||
public void play(MusicSound type) {
|
||||
}
|
||||
public void play(Music type) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue