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

Hi. I want to take a sreenshot via code. This is the code i found in Minecraft class.

private void screenshotListener()
    {
        if (Keyboard.isKeyDown(60))
        {
            if (!this.isTakingScreenshot)
            {
                this.isTakingScreenshot = true;
                this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(minecraftDir, 
                   this.displayWidth, this.displayHeight));
            }
        }
        else
        {
            this.isTakingScreenshot = false;
        }
    }

This is mine code

public boolean onItemUse(ItemStack item, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffSet)
{
   blablabla
   File phDir = mine.getAppDir("minecraft");
   mine.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(phDir, 
      mine.displayWidth, mine.displayHeight));
   world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
   blablabla
   return true;
}

And i'm getting an error

2013-05-05 14:48:35 [iNFO] [sTDERR] java.lang.NullPointerException
2013-05-05 14:48:35 [iNFO] [sTDERR] 	at org.lwjgl.opengl.GL11.glPixelStorei(GL11.java:2135)
2013-05-05 14:48:35 [iNFO] [sTDERR] 	at net.minecraft.util.ScreenShotHelper.func_74292_a(ScreenShotHelper.java:45)
2013-05-05 14:48:35 [iNFO] [sTDERR] 	at net.minecraft.util.ScreenShotHelper.saveScreenshot(ScreenShotHelper.java:28)
2013-05-05 14:48:35 [iNFO] [sTDERR] 	at net.obscuracraft.src.ItemPlate.onItemUse(ItemPlate.java:84)

Any ideas?

 

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • 2 weeks later...
  • Author

Well, unlike some persons i don't make a secret of my code, so here's the solution.

robot = new Robot();
BufferedImage shot = robot.createScreenCapture(x, y, w, h);

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author
Oh dear.
What do you want to say, darling?

 

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author

Oh, but it actually works. Will tell the right way then?

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author

Suggest alternatives if so.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author

For me it throws null exception.

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

  • Author

You are just lucky...

If i helped you, don't forget pressing "Thank You" button. Thanks for your time.

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.