Skip to content

Instantly share code, notes, and snippets.

@Corosauce
Created February 4, 2016 15:52
Show Gist options
  • Save Corosauce/6e9cce61145139e3718a to your computer and use it in GitHub Desktop.
Save Corosauce/6e9cce61145139e3718a to your computer and use it in GitHub Desktop.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void tickClient(ClientTickEvent event) {
try {
if (Minecraft.getMinecraft().currentScreen instanceof GuiInventory) {
GuiInventory gui = (GuiInventory) Minecraft.getMinecraft().currentScreen;
Slot slot = gui.getSlotUnderMouse();
if (slot != null) {
int guiLeft = ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, gui, "guiLeft");
int guiTop = ObfuscationReflectionHelper.getPrivateValue(GuiContainer.class, gui, "guiTop");
Mouse.setCursorPosition(guiLeft + slot.xDisplayPosition + 8, guiTop + slot.yDisplayPosition + 8);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment