Jump to content

The Box

Members
  • Posts

    3
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

The Box's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. How do I take a screenshot on the client when an item is right clicked and then send that image over to the server in a packet and use it there?
  2. I fixed this by removing the "!" on "!worldIn.isRemote"
  3. I'm trying to take a screenshot and then save that in Item nbt with a byte array: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (!worldIn.isRemote) { ItemStack stack = new ItemStack(ModItems.PICTURE); NBTTagCompound nbt; if (stack.hasTagCompound()) { nbt = stack.getTagCompound(); } else { nbt = new NBTTagCompound(); } BufferedImage screenshot = new ScreenShotHelper().createScreenshot(Main.mc.displayWidth, Main.mc.displayHeight, Main.mc.getFramebuffer()); byte[] bytes = null; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); boolean foundWriter; foundWriter = ImageIO.write(screenshot, "jpg", baos); assert foundWriter; bytes = baos.toByteArray(); } catch (IOException e) { e.printStackTrace(); } nbt.setByteArray("Picture", bytes); stack.setTagCompound(nbt); } return super.onItemRightClick(worldIn, playerIn, handIn); } But I get the error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: No OpenGL context found in the current thread. at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_192] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_192] at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:798) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_192] Caused by: java.lang.RuntimeException: No OpenGL context found in the current thread. at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124) ~[lwjgl-2.9.4-nightly-20150209.jar:?] at org.lwjgl.opengl.GL11.glPixelStorei(GL11.java:2155) ~[lwjgl-2.9.4-nightly-20150209.jar:?] at net.minecraft.client.renderer.GlStateManager.glPixelStorei(GlStateManager.java:806) ~[GlStateManager.class:?] at net.minecraft.util.ScreenShotHelper.createScreenshot(ScreenShotHelper.java:99) ~[ScreenShotHelper.class:?] at com.thebox.guac.items.ItemCamera.onItemRightClick(ItemCamera.java:53) ~[ItemCamera.class:?] at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:234) ~[ItemStack.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:384) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItem(NetHandlerPlayServer.java:796) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_192] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_192] at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?] ... 5 more Anyone know why? (I'm new to Java/Modding)
×
×
  • Create New...

Important Information

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