Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/10/20 in all areas

  1. this.addLayer(new HeldItemLayer(this)); Add this into your renderer constructor. On an unrelated note, you seem to be registering your entity World spawns at the entity registry event. I am not entirely sure if that's the correct place to register those. At least you do it after you register your entities, so I guess there is no problem. Anyway just saying, someone more knowledgeable than me can perhaps give you more information on that.
    1 point
  2. https://github.com/MinecraftForge/MinecraftForge/tree/1.15.x/mdk
    1 point
  3. By simple GUI you mean you just want to draw a string? You can just invoke the fontrenderer in the Minecraft class (make sure you are on the client): fontRenderer.drawString(String, x, y, color);
    1 point
  4. Dude. This isn't that hard. Loot tables are json files. Put the json files in the right location and it happens automagically.
    1 point
  5. Okay, I normally do not provide people with ready-to-use code because it is my firm belief that people need to learn how to code themselves, not use ready solutions. However this might be a special case because it requires a descent OpenGL knowledge that you might not be willing to learn because you don't really need it in minecraft modding or even usual java programming. It is also quite difficult to understand out of the box if you've never worked with it before. So I will deviate from my usual ideas and provide you with some code that will be commented so you have an understanding of what's going on and can actually learn something from it. // Define the width and the height of the framebuffer, the texture and as a result the final png file. int width = 256; int height = 256; // Get the framebuffer object that was already in use since we have to restore the state when we are done Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer(); // Create a new framebuffer object with the width and the height defined. The last parameter defines whether to use depth or not. Framebuffer framebuffer = new Framebuffer(width, height, true); // Bind the created framebuffer as the active framebuffer. The last parameter also adjusts the viewport to the dimensions of our framebuffer. framebuffer.bindFramebuffer(true); // These are not really needed, however I prefer do draw over black. By default the texture would be white. GlStateManager.clearColor(0, 0, 0, 1); // No need to clear depth/stencil since those are clean as is since nothing has been drawn yet. GlStateManager.clear(GL11.GL_COLOR_BUFFER_BIT); // Draw the actual entity. You might want to play with positions and scaling. GuiInventory.drawEntityOnScreen(200, 200, 100, 0, 0, new EntitySheep(Minecraft.getMinecraft().world)); // Alternatively if the GL matrix isn't as desired: /* GlStateManager.pushMatrix(); // Do matrix manipulations - scaling, translating, rotating. GuiInventory.drawEntityOnScreen(200, 200, 100, 0, 0, new EntitySheep(Minecraft.getMinecraft().world)); GlStateManager.popMatrix(); */ // Allocate a buffer for GL to dump pixels into. IntBuffer pixels = BufferUtils.createIntBuffer(width * height); // Bind the framebuffer's texture. GlStateManager.bindTexture(framebuffer.framebufferTexture); // Dump the pixels onto the IntBuffer. Note that the pixel format is BGRA and the pixel type is 8 bits per color. GlStateManager.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixels); // Allocate the array to hold pixel values. int[] vals = new int[width * height]; // Copy the buffer to the array. pixels.get(vals); // Rearrange pixel values to correct positions so they can be read by the BufferedImage correctly. TextureUtil.processPixelValues(vals, width, height); // Create the BufferedImage object. BufferedImage bufferedimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // Copy the pixels from the array onto the BufferedImage. bufferedimage.setRGB(0, 0, width, height, vals, 0, width); // Create a file to store the image within. Here the file will be outputted to the game's base directory with a name of img.png. File f = new File(Minecraft.getMinecraft().mcDataDir, "img.png"); f.createNewFile(); // Finally write the buffered image into the file. ImageIO.write(bufferedimage, "png", f); // Delete the framebuffer from memory. It is no longer needed. framebuffer.deleteFramebuffer(); // If the game had a buffer bound. In most cases it did but who knows what could be the case with mods and such. if (fbo != null) { // Restore the original framebuffer. The parameter set to true also restores the viewport. fbo.bindFramebuffer(true); } else { // If the game didn't have a framebuffer bound we need to restore the default one. It's ID is always 0. GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0); // We also need to restore the viewport back in this case. GL11.glViewport(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight); } And here is the resulting image: Note that you must do all this in a thread that is the main render thread!
    1 point
×
×
  • Create New...

Important Information

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