aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dulkirmod/mixins/MixinGuiScreen.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dulkirmod/mixins/MixinGuiScreen.java')
-rw-r--r--src/main/java/dulkirmod/mixins/MixinGuiScreen.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/dulkirmod/mixins/MixinGuiScreen.java b/src/main/java/dulkirmod/mixins/MixinGuiScreen.java
new file mode 100644
index 0000000..fa4c857
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinGuiScreen.java
@@ -0,0 +1,32 @@
+package dulkirmod.mixins;
+
+import dulkirmod.features.ScalableTooltips;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.inventory.Slot;
+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 {
+
+ private static int previousSlotId = -1;
+
+ @Inject(method = "renderToolTip", at = @At("HEAD"))
+ public void onTooltip(ItemStack stack, int x, int y, CallbackInfo ci) {
+ GuiScreen screen = (GuiScreen) (Object) this;
+ if (screen instanceof GuiContainer) {
+ GuiContainer containerScreen = (GuiContainer) screen;
+ Slot slot = containerScreen.getSlotUnderMouse();
+ if (slot != null && slot.slotNumber != previousSlotId) {
+ ScalableTooltips.INSTANCE.resetPos();
+ previousSlotId = slot.slotNumber;
+ }
+ }
+ }
+
+
+}