blob: fa4c85723c0f13fce77fae8c4f518b230c0e6d63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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;
}
}
}
}
|