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.

Featured Replies

Posted

Developing a mod with 1.15.2, am getting

java.awt.HeadlessException

from 

PointerInfo pointerInfo = MouseInfo.getPointerInfo();

Have been looking at this excellent example: motecraft, although it is out of date, so for 1.15.2 am using the following:

DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
    initRobot();
});

void initRobot() {

    try {
        this.robot = new Robot();
    } catch (AWTException e){
        e.printStackTrace();
    }

    PointerInfo pointerInfo = MouseInfo.getPointerInfo();

	DisplayMode mode = pointerInfo.getDevice().getDisplayMode();

	int width = mode.getWidth();
    int height = mode.getHeight();

    this.displayPixels = height < width ? height : width;
}

Have tried many, many variations, but no way to avoid the exception. 

Can anyone indicate whether the Minecraft 1.15.2 client is headless? Or is there something obvious I've missed.

Any info greatly appreciated.

  • Author

Finally cracked it. In case useful to anyone else, in the client you have to manually clear the headless state:

MyClassConstructor() {

    // ....

    DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> {
        initRobot();
    });
}

void initRobot() {

    System.setProperty("java.awt.headless", "false");

    try {
        this.robot = new Robot();
    } catch (AWTException e){
        e.printStackTrace();
    }

    PointerInfo pointerInfo = MouseInfo.getPointerInfo();

    // you can now use all the usual Robot class methods

}

 

  • 9 months later...
  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.