Merge remote-tracking branch 'origin/1.20' into 1.21.1
This commit is contained in:
commit
1f15c277ab
|
|
@ -1,29 +0,0 @@
|
|||
package org.embeddedt.modernfix.common.mixin.perf.dynamic_sounds;
|
||||
|
||||
import com.mojang.blaze3d.audio.SoundBuffer;
|
||||
import net.minecraft.client.sounds.SoundBufferLibrary;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.embeddedt.modernfix.dynamicresources.DynamicSoundHelpers;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
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 java.util.concurrent.CompletableFuture;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(SoundBufferLibrary.class)
|
||||
@ClientOnlyMixin
|
||||
public abstract class SoundBufferLibraryMixin {
|
||||
@Shadow @Final @Mutable
|
||||
private Map<ResourceLocation, CompletableFuture<SoundBuffer>> cache;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void replaceCache(CallbackInfo ci) {
|
||||
this.cache = new DynamicSoundHelpers.Cache(cache);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
package org.embeddedt.modernfix.common.mixin.perf.dynamic_sounds;
|
||||
|
||||
import com.mojang.blaze3d.audio.SoundBuffer;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.embeddedt.modernfix.dynamicresources.DynamicSoundHelpers;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@ClientOnlyMixin
|
||||
@Mixin(SoundBuffer.class)
|
||||
public class SoundBufferMixin implements DynamicSoundHelpers.SoundBufAccess {
|
||||
@Unique
|
||||
private long mfix$durationNanos;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void computeDuration(ByteBuffer data, AudioFormat format, CallbackInfo ci) {
|
||||
if (data != null) {
|
||||
int numFrames = data.capacity() / format.getFrameSize();
|
||||
double seconds = ((double)numFrames / format.getFrameRate());
|
||||
mfix$durationNanos = Math.max(0, (long)Math.ceil(seconds * 1_000_000_000.0));
|
||||
} else {
|
||||
mfix$durationNanos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long mfix$getDurationNanos() {
|
||||
return mfix$durationNanos;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user