vanilla-fixes

Minecraft: Better than Adventure! mod that fixes some issues
git clone git://memoryshards.xyz/vanilla-fixes.git
Log | Files | Refs | README | LICENSE

SoundManagerMixin.java (2038B)


      1 package ambos.vanillafixes.mixin;
      2 
      3 import net.minecraft.client.Minecraft;
      4 import net.minecraft.client.sound.SoundManager;
      5 import org.spongepowered.asm.mixin.Mixin;
      6 import org.spongepowered.asm.mixin.injection.At;
      7 import org.spongepowered.asm.mixin.injection.ModifyArgs;
      8 import org.spongepowered.asm.mixin.injection.Redirect;
      9 import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
     10 
     11 import ambos.vanillafixes.VanillaFixes;
     12 
     13 import java.io.File;
     14 
     15 @Mixin(value = SoundManager.class, remap = false)
     16 final class SoundManagerMixin {
     17     @Redirect(method = "loadModAudio", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getAppDir(Ljava/lang/String;)Ljava/io/File;", ordinal = 0))
     18     private static File doNotGetAppDir(String s) {
     19         if (VanillaFixes.MOD_RESOURCES_PATH) {
     20             return new File(s);
     21         }
     22 
     23         return Minecraft.getAppDir(s);
     24     }
     25 
     26     @ModifyArgs(method = "loadSoundSettings", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sound/SoundManager;loadModAudio(Ljava/lang/String;Lnet/minecraft/client/sound/SoundPool;)V"), require = 0)
     27     private void changeModResourcesPath(Args args) {
     28         if (VanillaFixes.MOD_RESOURCES_PATH) {
     29             // Note: "mod" directory is now inside .minecraft/resources instead of
     30             // $HOME/.minecraft-bta/resources (MultiMC users should be happy)
     31             Minecraft mc = Minecraft.getMinecraft(Minecraft.class);
     32 
     33             if (args.get(0).equals("minecraft-bta/resources/mod/sound")) {
     34                 args.set(0, mc.getMinecraftDir() + "/resources/mod/sound");
     35             } else if (args.get(0).equals("minecraft-bta/resources/mod/streaming")) {
     36                 args.set(0, mc.getMinecraftDir() + "/resources/mod/streaming");
     37             } else if (args.get(0).equals("minecraft-bta/resources/mod/music")) {
     38                 args.set(0, mc.getMinecraftDir() + "/resources/mod/music");
     39             } else {
     40                 args.set(0, mc.getMinecraftDir() + "/resources/mod/cavemusic");
     41             }
     42         }
     43     }
     44 }