How to extract sign text from .mca file in Minecraft?
I am writing a script that locates all the signs in my old multiplayer Minecraft world save. I want to retrieve text on these signs and store/present it somewhere.
I am leveraging anvil parser to find where signs actually are in the region's chunk - and I get all the way up to the point where I have the sign block instance available. When I print out the properties
, I get only waterlogged
and rotation
information.
Where is the actual text stored in the .mca
file? And what would be the best way to access it give I currently have only block's local coordinates (meaning it's coordinates within the chunk it is located in)?
Note that this is not meant to be "looking for support for this parser I use". I know that there are people on this exchange who are familiar with .mca
and nbt
format, who could provide me insight into where and how to look for this kind of information. While I referenced the specific parser to give provide sufficient context, I am open to using just about any approach/technology to do this.
Solution 1:
The text of the sign is stored in a Block entity (also called a tile entity), rather than as part of the block state. Looking at the source code for your parser, you can access the contents of the block entity by calling the get_tile_entity(x, y, z)
. (This does mean that I don't think there is a way of getting the tile entity only knowing it's chunk-local coordinates, since tile entities are identified in the MCA file by their global coordinates)
Once you have found the relevant block entity, the text of the sign is it's Text1
through Text4
properties, in JSON format.