diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinGuiScreen.java | 32 | ||||
-rw-r--r-- | src/main/java/dulkirmod/mixins/MixinItemStack.java | 27 |
2 files changed, 32 insertions, 27 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; + } + } + } + + +} diff --git a/src/main/java/dulkirmod/mixins/MixinItemStack.java b/src/main/java/dulkirmod/mixins/MixinItemStack.java deleted file mode 100644 index 76440ef..0000000 --- a/src/main/java/dulkirmod/mixins/MixinItemStack.java +++ /dev/null @@ -1,27 +0,0 @@ -package dulkirmod.mixins; -import dulkirmod.features.ScalableTooltips; -import net.minecraft.entity.player.EntityPlayer; -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.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(ItemStack.class) -public abstract class MixinItemStack { - - private static ItemStack previousStack; - - @Inject(method = "getTooltip", at = @At("HEAD")) - public void onTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable<List<String>> cir) { - - ItemStack currentStack = (ItemStack)(Object)this; - if (currentStack != previousStack) { - // reset values here for scrollable tooltips - ScalableTooltips.INSTANCE.resetPos(); - previousStack = currentStack; - } - } -} |