From 4d89d1b3b1ff285db03ea244be5c66391d1b82df Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 10 Apr 2023 22:05:11 +0200 Subject: Created RenderItemTooltipEvent and used it in EstimatedItemValue as a workaround for a bug caused in ct or hu3 --- .../at/hannibal2/skyhanni/events/RenderTooltipEvent.kt | 5 +++++ .../skyhanni/features/misc/EstimatedItemValue.kt | 6 +++--- .../hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt | 8 ++++++++ .../mixins/transformers/gui/MixinGuiScreen.java | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/events/RenderTooltipEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderTooltipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderTooltipEvent.kt new file mode 100644 index 000000000..0fbbc46d2 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/RenderTooltipEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import net.minecraft.item.ItemStack + +class RenderItemTooltipEvent(val stack: ItemStack): LorenzEvent() \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt index 50dd686aa..36e385d25 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/EstimatedItemValue.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.misc import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.RenderItemTooltipEvent import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name @@ -38,7 +39,6 @@ import io.github.moulberry.moulconfig.internal.KeybindHelper import io.github.moulberry.notenoughupdates.util.Constants import net.minecraft.init.Items import net.minecraft.item.ItemStack -import net.minecraftforge.event.entity.player.ItemTooltipEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class EstimatedItemValue { @@ -63,11 +63,11 @@ class EstimatedItemValue { } @SubscribeEvent - fun onItemTooltipLow(event: ItemTooltipEvent) { + fun onRenderitemTooltip(event: RenderItemTooltipEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.estimatedIemValueEnabled) return - val item = event.itemStack + val item = event.stack val oldData = cache[item] if (oldData != null) { display = oldData diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt new file mode 100644 index 000000000..6ed537234 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/GuiScreenHook.kt @@ -0,0 +1,8 @@ +package at.hannibal2.skyhanni.mixins.hooks + +import at.hannibal2.skyhanni.events.RenderItemTooltipEvent +import net.minecraft.item.ItemStack + +fun renderToolTip(stack: ItemStack) { + RenderItemTooltipEvent(stack).postAndCatch() +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java new file mode 100644 index 000000000..9da6faf3a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java @@ -0,0 +1,18 @@ +package at.hannibal2.skyhanni.mixins.transformers.gui; + +import at.hannibal2.skyhanni.mixins.hooks.GuiScreenHookKt; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.item.ItemStack; +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.CallbackInfo; + +@Mixin(GuiScreen.class) +public class MixinGuiScreen { + + @Inject(method = "renderToolTip", at = @At("TAIL")) + public void renderToolTip(ItemStack stack, int x, int y, CallbackInfo ci) { + GuiScreenHookKt.renderToolTip(stack); + } +} -- cgit