2

This is my first question on any forum, so any advice would be helpful; down voting doesn't count as advice :) Also, I am not sure if this is the right forum, or if Stack Overflow is better ... any pointers are very helpful!

I am creating a world viewing and editing software for Minecraft in Java as MC Edit has been broken for a long time. Currently, I am able to get the Minecraft id of the top block in every x and z coordinate pair. Now, I need to get the texture of these blocks. (Just to be clear, the id I am talking about is like this: minecraft:bedrock, not the number) Is there an easy way to get the file name of the texture from the id? I plan to then create a BufferedImage and render the texture onto the screen, to get a realistic overview of the world.

This would need to account for the blocks with different textures on the sides, blocks with only one texture, and so on. If possible, I would like to be able to show the tops of chests, item frames, and more, accurately, but that might be more difficult. So far, the only idea I have gotten is to map all the file names to the id, which could take a while.

Thank You!

6
  • Nitpick: StackExchange does not see itself as a "forum", to differentiate it from forums in which people discuss back and forth until there's finally a solution on page 10 and then there's more discussion. See also: tour. But anyway, almost all Minecraft questions are on-topic here and none on another SE site, except for mod development, on gamedevSE. But I don't really understand your question. Do you want some kind of API to Minecraft? That doesn't exist for textures, you can only get the default resource pack from the versions folder. Are you trying to get all model and texture files ... Apr 13, 2020 at 11:50
  • ... for a block from a program? That might be much more difficult than you think, because there are model files that can reference multiple texture files, both can be overwritten by resource packs and so on. You would have to re-implement Minecraft's block rendering. And just look at the lectern, that can get pretty complicated. (Also, is it intentional that you listed HTML as the first "programming language" on your profile?) Apr 13, 2020 at 11:56
  • @FabianRöling Thank you for clarifying the forum stuff! That is really helpful. As a solution, I plan to make a program that checks for the existence of the block name, the block name with _top added to the end, and then for an error to occur. It saves the correct texture name in a file for reference later. For some blocks (like water, the lectern, and so on) I plan to make a custom texture which I can point to in the reference file. Thank you for your help! Apr 13, 2020 at 23:02
  • @FabianRöling I can't find where to edit my top tags ... I think HTML is the top since most questions on Stack Overflow that I answered had HTML as an attached tag. But, I do program in HTML a lot, so you could say that that is intentional :) Apr 13, 2020 at 23:13
  • 1
    @FabianRöling I am trying to make a program to be able to see a Minecraft world and edit it. To make it easy to see what block everything is, I am trying to load the texture. I am currently only planning to make it so you can see the top of the blocks, as the 3D viewing would be very difficult, and unnecessary for the application. After I get this working, I am going to make support for resource packs. This is mainly so modded worlds can still have the blocks shown, instead of an error appearing. I don't need the image to be perfect, just good enough for the user to understand what they see. Apr 13, 2020 at 23:29

1 Answer 1

0

Most blocks use a "normal cube" model, meaning six sides, following a standard naming scheme. But some blocks are much more complex, like redstone wire (whose connection directions were not even saved to file until 1.13), lecterns (with a diagonal "top" face), plants (which are basically invisible from the top) and so on.

If you want to display them from any angle, including the top, you will always need to parse that block's block model (archive). This is done in four main steps:

  1. Find the default resources: The path of the default .minecraft folder (archive) depends on the operating system, but not on launcher profiles. In there you can find (archive) the file versions/<version>/<version>.jar, which you can unpack as an archive. The file structure inside is explained here (archive) and in more detail the resource pack structure here (archive).
  2. Parse the <id>.json file (with <id> being the ID you know) in the assets/minecraft/blockstates folder, which references the different block states this block can have and the blockstate files that they use.
  3. Parse the <blockstate>.json model files in assets/minecraft/models/block that the block state file referenced. Either decide somehow what you consider the "top" or make a full 3D render, both using …
  4. … the <texture>.png image files in assets/minecraft/textures/block that the model file referenced.

This will certainly not be a small project …

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .