Jump to content

[Solved]Taking sreenshots?


Naiten

Recommended Posts

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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