From 334ef4c0c49d48e649209676a69f0dacf81b112f Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:29:32 +1000 Subject: Fix: Some stuff in garden tooltips not showing (#2018) Co-authored-by: VixidDev <52578495+vixiddev@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt | 9 ++++++++- .../skyhanni/features/garden/visitor/VisitorListener.kt | 7 +++---- .../hannibal2/skyhanni/mixins/transformers/MixinItemStack.java | 7 ++++--- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt index 2b3041d62..343883841 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/item/ItemHoverEvent.kt @@ -3,4 +3,11 @@ 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) : LorenzEvent() +class ItemHoverEvent(val itemStack: ItemStack, private val toolTip0: MutableList) : LorenzEvent() { + var toolTip + set(value) { + toolTip0.clear() + toolTip0.addAll(value) + } + get() = toolTip0 +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index 0f474f129..39c1f90c5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -6,12 +6,12 @@ import at.hannibal2.skyhanni.events.GuiKeyPressEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent import at.hannibal2.skyhanni.events.LorenzRenderWorldEvent -import at.hannibal2.skyhanni.events.LorenzToolTipEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorOpenEvent import at.hannibal2.skyhanni.events.garden.visitor.VisitorRenderEvent +import at.hannibal2.skyhanni.events.item.ItemHoverEvent import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.ACCEPT_SLOT import at.hannibal2.skyhanni.features.garden.visitor.VisitorAPI.INFO_SLOT @@ -33,7 +33,6 @@ import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.entity.item.EntityArmorStand import net.minecraft.network.play.client.C02PacketUseEntity -import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import kotlin.time.Duration.Companion.seconds @@ -133,8 +132,8 @@ object VisitorListener { inventory.handleMouseClick_skyhanni(slot, slot.slotIndex, 0, 0) } - @SubscribeEvent(priority = EventPriority.HIGH) - fun onTooltip(event: LorenzToolTipEvent) { + @SubscribeEvent + fun onTooltip(event: ItemHoverEvent) { if (!GardenAPI.onBarnPlot) return if (!VisitorAPI.inInventory) return val visitor = VisitorAPI.getVisitor(lastClickedNpc) ?: 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 5dfde6d70..a5a6fad3c 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinItemStack.java @@ -10,6 +10,7 @@ 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 org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.List; @@ -23,9 +24,9 @@ public class MixinItemStack implements ItemStackCachedData { return skyhanni_cachedData; } - @Inject(method = "getTooltip", at = @At("RETURN")) - public void getTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable> ci) { + @Inject(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/event/ForgeEventFactory;onItemTooltip(Lnet/minecraft/item/ItemStack;Lnet/minecraft/entity/player/EntityPlayer;Ljava/util/List;Z)Lnet/minecraftforge/event/entity/player/ItemTooltipEvent;", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) + public void getTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable> cir, List list) { ItemStack stack = (ItemStack) (Object) this; - ToolTipData.onHover(stack, ci.getReturnValue()); + ToolTipData.onHover(stack, list); } } -- cgit