forked from WildBamaBoy/minecraft-comes-alive
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e031063
commit 44eda0b
Showing
5 changed files
with
39 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
common/src/main/java/net/mca/mixin/client/MixinResourceFactory.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
common/src/main/java/net/mca/mixin/client/MixinSoundLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.mca.mixin.client; | ||
|
||
import net.minecraft.client.sound.AudioStream; | ||
import net.minecraft.client.sound.OggAudioStream; | ||
import net.minecraft.client.sound.RepeatingAudioStream; | ||
import net.minecraft.client.sound.SoundLoader; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.util.Util; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionException; | ||
|
||
@Mixin(SoundLoader.class) | ||
public class MixinSoundLoader { | ||
@Inject(method = "loadStreamed(Lnet/minecraft/util/Identifier;Z)Ljava/util/concurrent/CompletableFuture;", at = @At("HEAD"), cancellable = true) | ||
void mca$injectLoadStreamed(Identifier id, boolean repeatInstantly, CallbackInfoReturnable<CompletableFuture<AudioStream>> cir) { | ||
if (id.getPath().startsWith("sounds/tts_cache/")) { | ||
cir.setReturnValue(CompletableFuture.supplyAsync(() -> { | ||
try { | ||
InputStream inputStream = new FileInputStream(id.getPath().replace("sounds/", "")); | ||
return repeatInstantly ? new RepeatingAudioStream(OggAudioStream::new, inputStream) : new OggAudioStream(inputStream); | ||
} catch (IOException iOException) { | ||
throw new CompletionException(iOException); | ||
} | ||
}, Util.getMainWorkerExecutor())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters