aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-05-30 06:17:41 +1000
committerGitHub <noreply@github.com>2024-05-29 22:17:41 +0200
commit28efe42942ead21fb4ba9fa16e132975e34f65fb (patch)
tree4bb8330b0832bd183f0736535866faeaa49b390f
parent56f13597822b45caea4167d7d75258078e06c1b3 (diff)
downloadskyhanni-28efe42942ead21fb4ba9fa16e132975e34f65fb.tar.gz
skyhanni-28efe42942ead21fb4ba9fa16e132975e34f65fb.tar.bz2
skyhanni-28efe42942ead21fb4ba9fa16e132975e34f65fb.zip
Fix: tooltip event (#1920)
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java12
3 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt
index 709961ce6..258cb244e 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt
@@ -11,6 +11,8 @@ import net.minecraft.item.ItemStack
// Please use LorenzToolTipEvent over ItemTooltipEvent if no special EventPriority is necessary
object ToolTipData {
+
+ @JvmStatic
fun getTooltip(stack: ItemStack, toolTip: MutableList<String>): List<String> {
onHover(stack, toolTip)
return onTooltip(toolTip)
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java
index 75c94b0b6..b96075d62 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java
@@ -1,17 +1,10 @@
package at.hannibal2.skyhanni.mixins.transformers;
-import at.hannibal2.skyhanni.data.ToolTipData;
import at.hannibal2.skyhanni.mixins.hooks.ItemStackCachedData;
import at.hannibal2.skyhanni.utils.CachedItemData;
-import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
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.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-
-import java.util.List;
@Mixin(ItemStack.class)
public class MixinItemStack implements ItemStackCachedData {
@@ -22,10 +15,4 @@ public class MixinItemStack implements ItemStackCachedData {
public CachedItemData getSkyhanni_cachedData() {
return skyhanni_cachedData;
}
-
- @Inject(method = "getTooltip", at = @At("RETURN"))
- public void getTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable<List<String>> ci) {
- ItemStack stack = (ItemStack) (Object) this;
- ToolTipData.INSTANCE.getTooltip(stack, ci.getReturnValue());
- }
}
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
index 9da6faf3a..dee6be23e 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/gui/MixinGuiScreen.java
@@ -1,5 +1,6 @@
package at.hannibal2.skyhanni.mixins.transformers.gui;
+import at.hannibal2.skyhanni.data.ToolTipData;
import at.hannibal2.skyhanni.mixins.hooks.GuiScreenHookKt;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.item.ItemStack;
@@ -7,6 +8,9 @@ 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;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
+import java.util.List;
@Mixin(GuiScreen.class)
public class MixinGuiScreen {
@@ -15,4 +19,12 @@ public class MixinGuiScreen {
public void renderToolTip(ItemStack stack, int x, int y, CallbackInfo ci) {
GuiScreenHookKt.renderToolTip(stack);
}
+
+ @Inject(method = "renderToolTip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getRarity()Lnet/minecraft/item/EnumRarity;", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
+ public void getTooltip(ItemStack stack, int x, int y, CallbackInfo ci, List<String> list, int i) {
+ ToolTipData.getTooltip(stack, list);
+ if (list.isEmpty()) {
+ ci.cancel();
+ }
+ }
}