From 228eb4944dd2067c4dbdbcd1018be35f5ce261e3 Mon Sep 17 00:00:00 2001 From: dima_dencep Date: Mon, 11 Mar 2024 17:29:41 +0700 Subject: [PATCH] Improve compatibility by using mixinextra (1.20.1) --- .../mixin/animation/MixinSpriteAtlasTexture.java | 9 +++++---- .../mixin/reduce_resolution_on_mac/MixinWindow.java | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java index 5f19d1088..8de453adb 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/animation/MixinSpriteAtlasTexture.java @@ -1,5 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.animation; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.texture.AbstractTexture; import net.minecraft.client.texture.Sprite; @@ -8,7 +10,6 @@ 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.Redirect; import java.util.List; import java.util.Map; @@ -19,9 +20,9 @@ public abstract class MixinSpriteAtlasTexture extends AbstractTexture { @Unique private final Map, List> animatedSprites = constructAnimatedSprites(); - @Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/Sprite;createAnimation()Lnet/minecraft/client/texture/Sprite$TickableAnimation;")) - public Sprite.TickableAnimation sodiumExtra$tickAnimatedSprites(Sprite instance) { - Sprite.TickableAnimation tickableAnimation = instance.createAnimation(); + @WrapOperation(method = "upload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/Sprite;createAnimation()Lnet/minecraft/client/texture/Sprite$TickableAnimation;")) + public Sprite.TickableAnimation sodiumExtra$tickAnimatedSprites(Sprite instance, Operation original) { + Sprite.TickableAnimation tickableAnimation = original.call(instance); if (tickableAnimation != null && SodiumExtraClientMod.options().animationSettings.animation && this.shouldAnimate(instance.getContents().getId())) return tickableAnimation; return null; diff --git a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java index 788d4f6aa..c013dca02 100644 --- a/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java +++ b/src/main/java/me/flashyreese/mods/sodiumextra/mixin/reduce_resolution_on_mac/MixinWindow.java @@ -1,5 +1,7 @@ package me.flashyreese.mods.sodiumextra.mixin.reduce_resolution_on_mac; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod; import net.minecraft.client.MinecraftClient; import net.minecraft.client.util.Window; @@ -8,7 +10,6 @@ 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; /** @@ -28,13 +29,13 @@ public class MixinWindow { @Shadow private int framebufferHeight; - @Redirect(at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwWindowHint(II)V", ordinal = 0), method = "", remap = false) - private void onDefaultWindowHints(int hint, int value) { + @WrapOperation(at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwWindowHint(II)V", ordinal = 0), method = "", remap = false) + private void onDefaultWindowHints(int hint, int value, Operation original) { if (MinecraftClient.IS_SYSTEM_MAC && SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac) { - GLFW.glfwWindowHint(GLFW.GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW.GLFW_FALSE); + original.call(GLFW.GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW.GLFW_FALSE); } - GLFW.glfwWindowHint(hint, value); + original.call(hint, value); } @Inject(at = @At(value = "RETURN"), method = "updateFramebufferSize")