aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/items/EstimatedItemValue.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java3
4 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt
index c9bfd61cb..709961ce6 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ToolTipData.kt
@@ -1,14 +1,25 @@
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzToolTipEvent
+import at.hannibal2.skyhanni.events.item.ItemHoverEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
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
object ToolTipData {
+ 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
diff --git a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt
new file mode 100644
index 000000000..2b3041d62
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt
@@ -0,0 +1,6 @@
+package at.hannibal2.skyhanni.events.item
+
+import at.hannibal2.skyhanni.events.LorenzEvent
+import net.minecraft.item.ItemStack
+
+class ItemHoverEvent(val itemStack: ItemStack, val toolTip: List<String>) : LorenzEvent()
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 c79c1f8a4..299fe6ec5 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
@@ -7,10 +7,10 @@ import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuReforgeStoneJson
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.InventoryCloseEvent
-import at.hannibal2.skyhanni.events.LorenzToolTipEvent
import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent
import at.hannibal2.skyhanni.events.RenderItemTooltipEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.events.item.ItemHoverEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
@@ -63,7 +63,7 @@ object EstimatedItemValue {
}
@SubscribeEvent
- fun onTooltip(event: LorenzToolTipEvent) {
+ fun onTooltip(event: ItemHoverEvent) {
if (!LorenzUtils.inSkyBlock) return
if (!config.enabled) return
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 8eb61b979..75c94b0b6 100644
--- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java
@@ -25,6 +25,7 @@ public class MixinItemStack implements ItemStackCachedData {
@Inject(method = "getTooltip", at = @At("RETURN"))
public void getTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable<List<String>> ci) {
- ToolTipData.INSTANCE.onTooltip(ci.getReturnValue());
+ ItemStack stack = (ItemStack) (Object) this;
+ ToolTipData.INSTANCE.getTooltip(stack, ci.getReturnValue());
}
}