Posted May 5, 201312 yr 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.
May 13, 201312 yr 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.
May 13, 201312 yr 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.
May 13, 201312 yr 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.
May 13, 201312 yr Author Suggest alternatives if so. If i helped you, don't forget pressing "Thank You" button. Thanks for your time.
May 13, 201312 yr Author For me it throws null exception. If i helped you, don't forget pressing "Thank You" button. Thanks for your time.
May 13, 201312 yr 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.