Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.12.2] Hooking into LWJGL Minecraft window to add macOS Touch Bar features

Featured Replies

Posted

Hello everyone,

 

I am in the process of building a mod that will hook into Minecraft and display a widget for the touch bar in Minecraft Forge, but the API requires a LWJGL window handle in long format to properly display,

since the touch bar is based on the window currently in focus. I have it working with an auxiliary JFrame, but it disappears when Minecraft gains focus. Does anyone know of a way to retrieve the window long Minecraft uses?

 

Thank you.

  • Author
On 3/6/2018 at 4:30 PM, diesieben07 said:

Minecraft uses Display.create to create the display, which does not seem to expose a handle to the window directly.

Accessing Display.getImplementation using reflection and casting the result to MacOSXDisplay should give you access to some internals though, you'll have to see if you can find what you need.

Thank you for your response. I have done almost exactly that, and it appears I have access to a bunch of booleans and a ByteBuffer with variable name "window" of length 88. How would this be cast into an NSWindow ID? Also, in 1.13 with LWJGL 3 and GLFW, will this problem be made obsolete?

Screen Shot 2018-03-07 at 7.28.34 PM.png

  • Author
On 3/8/2018 at 3:56 AM, diesieben07 said:

I have no idea what an NSWindow ID is.

 

I do not know.

Oh sorry, NSWindow is a macOS specific format of window identification. It is an object, and it is a pain to work with.

https://developer.apple.com/documentation/appkit/nswindow

Thats the identification process and documentation file.

 

On 3/8/2018 at 4:05 PM, loordgek said:

 

loordgek, I am using that library actually, but getting the hook for the window is my main problem. I need a long that corresponds to the window Minecraft produces when launched so I can hook into and bind the Touch Bar to that specific window.

 

Beyond that, I have made some progress in extraction by reflection, but I seem to have hit a wall with ByteBuffers.

  • Author

I DID IT!!!!! The window ByteBuffer had to be converted into a Long Array very carefully, and then with trial and error I was able to extract the window's UUID! It's at position 5!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.