diff options
author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-06-01 19:27:51 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-01 11:27:51 +0200 |
commit | 83ed5f00e9943762d419e1b78f55942b15f9c99c (patch) | |
tree | 440786daf3917c59ca45d7dec80ab0d8ac660525 /src | |
parent | 7174c5eadbad4881c19f1ed5610285dc934741a1 (diff) | |
download | skyhanni-83ed5f00e9943762d419e1b78f55942b15f9c99c.tar.gz skyhanni-83ed5f00e9943762d419e1b78f55942b15f9c99c.tar.bz2 skyhanni-83ed5f00e9943762d419e1b78f55942b15f9c99c.zip |
Fix: Estimated item value not working in pv (#1955)
Diffstat (limited to 'src')
3 files changed, 27 insertions, 20 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt index 258cb244e..70cd9cd34 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt @@ -9,22 +9,13 @@ import at.hannibal2.skyhanni.utils.ItemUtils.name import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack -// Please use LorenzToolTipEvent over ItemTooltipEvent if no special EventPriority is necessary +// Please use LorenzToolTipEvent over ItemHoverEvent, ItemHoverEvent is only used for special use cases (e.g. neu pv) object ToolTipData { @JvmStatic - fun getTooltip(stack: ItemStack, toolTip: MutableList<String>): List<String> { - onHover(stack, toolTip) - return onTooltip(toolTip) - } - - private fun onHover(stack: ItemStack, toolTip: MutableList<String>) { - ItemHoverEvent(stack, toolTip).postAndCatch() - } - - fun onTooltip(toolTip: MutableList<String>): List<String> { - val slot = lastSlot ?: return toolTip - val itemStack = slot.stack ?: return toolTip + fun getTooltip(stack: ItemStack, toolTip: MutableList<String>) { + val slot = lastSlot ?: return + val itemStack = slot.stack ?: return try { if (LorenzToolTipEvent(slot, itemStack, toolTip).postAndCatch()) { toolTip.clear() @@ -42,7 +33,11 @@ object ToolTipData { "lore" to itemStack.getLore(), ) } - return toolTip + } + + @JvmStatic + fun onHover(stack: ItemStack, toolTip: MutableList<String>) { + ItemHoverEvent(stack, toolTip).postAndCatch() } var lastSlot: Slot? = null diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt index 299fe6ec5..b2fdf8294 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt @@ -66,14 +66,13 @@ object EstimatedItemValue { fun onTooltip(event: ItemHoverEvent) { if (!LorenzUtils.inSkyBlock) return if (!config.enabled) return + if (Minecraft.getMinecraft().currentScreen !is GuiProfileViewer) return - if (Minecraft.getMinecraft().currentScreen is GuiProfileViewer) { - if (renderedItems == 0) { - updateItem(event.itemStack) - } - tryRendering() - renderedItems++ + if (renderedItems == 0) { + updateItem(event.itemStack) } + tryRendering() + renderedItems++ } /** 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 b96075d62..a3c2f85de 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java @@ -1,10 +1,17 @@ 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 { @@ -15,4 +22,10 @@ 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.onHover(stack, ci.getReturnValue()); + } } |