From e4add25b320925f6253dcc3072834e71696c5d3a Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Tue, 22 Oct 2024 18:37:38 +0300 Subject: [PATCH] Update EMI and change Inject to ModifyReceiver in FakeScreenMixin --- gradle.properties | 2 +- .../mixins/emi/FakeScreenMixin.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index a8845a5a38..bcd3c88b95 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,7 +21,7 @@ mod_menu_version = 11.0.0-beta.1 ## REI (https://modrinth.com/mod/rei/versions?l=fabric) rei_version = 16.0.783 ## EMI (https://modrinth.com/mod/emi/versions) -emi_version = 1.1.10+1.21 +emi_version = 1.1.16+1.21.1 ## JEI (https://modrinth.com/mod/jei/versions) jei_version = 19.8.4.113 diff --git a/src/main/java/de/hysky/skyblocker/mixins/emi/FakeScreenMixin.java b/src/main/java/de/hysky/skyblocker/mixins/emi/FakeScreenMixin.java index f7ec8c7c46..70976f7a2d 100644 --- a/src/main/java/de/hysky/skyblocker/mixins/emi/FakeScreenMixin.java +++ b/src/main/java/de/hysky/skyblocker/mixins/emi/FakeScreenMixin.java @@ -1,5 +1,7 @@ package de.hysky.skyblocker.mixins.emi; +import com.llamalad7.mixinextras.injector.ModifyReceiver; +import com.llamalad7.mixinextras.sugar.Local; import de.hysky.skyblocker.utils.render.gui.AlignedTooltipComponent; import dev.emi.emi.screen.FakeScreen; import net.minecraft.client.MinecraftClient; @@ -10,22 +12,21 @@ import net.minecraft.text.MutableText; 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.util.List; +import java.util.stream.Collector; +import java.util.stream.Stream; -@Mixin(value = FakeScreen.class, remap = false) +@Mixin(value = FakeScreen.class) public class FakeScreenMixin { - @Inject(method = "getTooltipComponentListFromItem", at = @At(target = "Ljava/util/stream/Stream;collect(Ljava/util/stream/Collector;)Ljava/lang/Object;", value = "INVOKE", shift = At.Shift.AFTER), require = 0, cancellable = true) - private void skyblocker$alignedTooltip(ItemStack stack, CallbackInfoReturnable> cir) { - cir.setReturnValue(Screen.getTooltipFromItem(MinecraftClient.getInstance(), stack).stream().map(text -> { + @ModifyReceiver(method = "getTooltipComponentListFromItem", at = @At(target = "Ljava/util/stream/Stream;collect(Ljava/util/stream/Collector;)Ljava/lang/Object;", value = "INVOKE"), require = 0) + private Stream skyblocker$alignedTooltip(Stream instance, Collector> arCollector, @Local(argsOnly = true) ItemStack stack) { + return Screen.getTooltipFromItem(MinecraftClient.getInstance(), stack).stream().map(text -> { if (text instanceof MutableText mutableText) { MutableText firstOfChain = mutableText.getFirstOfChain(); if (firstOfChain != null) return new AlignedTooltipComponent(firstOfChain); else if (mutableText.getAlignedText() != null) return new AlignedTooltipComponent(mutableText); - else return new OrderedTextTooltipComponent(mutableText.asOrderedText()); - } else return new OrderedTextTooltipComponent(text.asOrderedText()); - }).toList()); + } return new OrderedTextTooltipComponent(text.asOrderedText()); + }); } }