From 6ba05f3d991efb93660f2e4d9be8f6719866706b Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Tue, 7 May 2019 11:49:09 +0200 Subject: [PATCH] Fix resource pack recorder mixin The old targets weren't inside the method but inside an inner class. --- .../mixin/MixinDownloadingPackFinder.java | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/replaymod/recording/mixin/MixinDownloadingPackFinder.java b/src/main/java/com/replaymod/recording/mixin/MixinDownloadingPackFinder.java index 6f2888e3..c0283853 100644 --- a/src/main/java/com/replaymod/recording/mixin/MixinDownloadingPackFinder.java +++ b/src/main/java/com/replaymod/recording/mixin/MixinDownloadingPackFinder.java @@ -5,16 +5,18 @@ import com.replaymod.recording.packet.ResourcePackRecorder; import de.johni0702.minecraft.gui.utils.Consumer; import net.minecraft.client.resources.DownloadingPackFinder; 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.Redirect; import java.io.File; -//#if MC>=11400 -//$$ import java.util.concurrent.CompletableFuture; +//#if MC>=10800 +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; //#else -import com.google.common.util.concurrent.ListenableFuture; +//$$ import org.spongepowered.asm.mixin.injection.Redirect; +//$$ import net.minecraft.util.HttpUtil; +//$$ import java.lang.reflect.Proxy; +//$$ import java.util.Map; //#endif @Mixin(DownloadingPackFinder.class) @@ -26,32 +28,27 @@ public abstract class MixinDownloadingPackFinder implements ResourcePackRecorder requestCallback = callback; } - @Shadow - public abstract - //#if MC>=11400 - //$$ CompletableFuture - //#else - ListenableFuture - //#endif - func_195741_a(File file); - - //#if MC>=11400 - //$$ @Redirect(method = "download", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resource/ClientResourcePackCreator;loadServerPack(Ljava/io/File;)Ljava/util/concurrent/CompletableFuture;")) - //$$ private CompletableFuture - //#else //#if MC>=10800 - @Redirect(method = "downloadResourcePack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/DownloadingPackFinder;func_195741_a(Ljava/io/File;)Lcom/google/common/util/concurrent/ListenableFuture;")) - //#else - //$$ @Redirect(method = "func_180601_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/ResourcePackRepository;func_177319_a(Ljava/io/File;)Lcom/google/common/util/concurrent/ListenableFuture;")) - //#endif - private ListenableFuture - //#endif - recordDownloadedPack(DownloadingPackFinder downloadingPackFinder, File file) { + @Inject(method = "func_195741_a", at = @At("HEAD")) + private void recordDownloadedPack(File file, CallbackInfoReturnable ci) { if (requestCallback != null) { requestCallback.consume(file); requestCallback = null; } - return func_195741_a(file); } + //#else + //$$ @Redirect(method = "func_148528_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/HttpUtil;downloadResourcePack(Ljava/io/File;Ljava/lang/String;Lnet/minecraft/util/HttpUtil$DownloadListener;Ljava/util/Map;ILnet/minecraft/util/HttpUtil$IProgressUpdate;Ljava/net/Proxy;)V")) + //$$ private void downloadResourcePack(File dst, String url, HttpUtil.DownloadListener callback, final Map headers, final int maxSize, final HttpUtil.IProgressUpdate progress, Proxy proxy) { + //$$ HttpUtil.downloadResourcePack(dst, url, new HttpUtil.DownloadListener() { + //$$ public void onDownloadComplete(File file) { + //$$ if (requestCallback != null) { + //$$ requestCallback.consume(file); + //$$ requestCallback = null; + //$$ } + //$$ callback.onDownloadComplete(file); + //$$ } + //$$ }, headers, maxSize, progress, proxy); + //$$ } + //#endif } //#endif