|
| 1 | +/* |
| 2 | + * This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client). |
| 3 | + * Copyright (c) Meteor Development. |
| 4 | + */ |
| 5 | + |
| 6 | +package meteordevelopment.meteorclient.mixin; |
| 7 | + |
| 8 | +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; |
| 9 | +import com.llamalad7.mixinextras.sugar.Local; |
| 10 | +import meteordevelopment.meteorclient.MeteorClient; |
| 11 | +import net.minecraft.util.Downloader; |
| 12 | +import org.spongepowered.asm.mixin.Final; |
| 13 | +import org.spongepowered.asm.mixin.Mixin; |
| 14 | +import org.spongepowered.asm.mixin.Shadow; |
| 15 | +import org.spongepowered.asm.mixin.injection.At; |
| 16 | + |
| 17 | +import java.nio.file.Path; |
| 18 | +import java.util.UUID; |
| 19 | + |
| 20 | +import static meteordevelopment.meteorclient.MeteorClient.mc; |
| 21 | + |
| 22 | +/** |
| 23 | + * Taken from <a href="https://github.com/CCBlueX/LiquidBounce">LiquidBounce</a> |
| 24 | + * <p> |
| 25 | + * Copyright (c) 2021 - 2025 CCBlueX |
| 26 | + * |
| 27 | + * @author Izuna |
| 28 | + * @see <a href="https://github.com/CCBlueX/LiquidBounce/blob/nextgen/src/main/java/net/ccbluex/liquidbounce/injection/mixins/minecraft/util/MixinDownloader.java">MixinDownloader.java</a> |
| 29 | + */ |
| 30 | +@Mixin(Downloader.class) |
| 31 | +public class DownloaderMixin { |
| 32 | + @Shadow |
| 33 | + @Final |
| 34 | + private Path directory; |
| 35 | + |
| 36 | + @ModifyExpressionValue(method = "method_55485", at = @At(value = "INVOKE", target = "Ljava/nio/file/Path;resolve(Ljava/lang/String;)Ljava/nio/file/Path;")) |
| 37 | + private Path hookResolve(Path original, @Local(argsOnly = true) UUID id) { |
| 38 | + UUID accountId = mc.getSession().getUuidOrNull(); |
| 39 | + if (accountId == null) { |
| 40 | + MeteorClient.LOG.warn("Failed to change resource pack download directory because the account id is null."); |
| 41 | + return original; |
| 42 | + } |
| 43 | + |
| 44 | + return directory.resolve(accountId.toString()).resolve(id.toString()); |
| 45 | + } |
| 46 | +} |
0 commit comments