Reading Region Files (.mca)

Discussion in 'Spigot Plugin Development' started by Serializator, May 21, 2017.

  1. Serializator

    Supporter

    Hello there!

    For a project that I'm working on I decided to use signs as configuration medium because signs are tile entities and easily retrievable from a chunk by using the Chunk#getTileEntities() method.

    Chunks are loaded when they're needed, so chunks that aren't needed aren't loaded. This is a problem if I want to get all the signs in the whole world. If I want to get all the signs from the whole world I'll have to load all the chunks that were ever generated, this information is located in the region files from the world (.mca files).

    Now the question is, how do I read those region files? I've never been good with reading from binary streams and such so I'd like some help with this part of the problem. I hope that someone knows how to do this and could help me.
     
  2. I did something very similar to this, I successfully made a program to get all books in a world and make an online archive. I used the official standalone code here to get the DataInputStream for chunks with a method I made to get all of the chunks in each region file, which were looped through the world file. With each DataInputStream, I used a class I found here to get usable NBT data. Get to the TileEntity section of the tag tree, and then you can easily get the data from signs if they are existent in that chunk.

    If you are really stuck or need more help, just ask me, or if you have the right idea and you want it, I can hand over some code. Not sure if any other people, or at least nobody I have found has done some stuff like this, and a lot of links are broken in the wikis I searched, but who doesn't like a good challenge :)

    Good luck!
     
    • Winner Winner x 2
  3. please like I can recover all the entities like for example armorstants of a region in particular I read the file and I can see its content but I do not have way of being able to catch the entities that it has. I am with version 1.12 I have tried to use the NBTTagCompound but I can not get it I can only see the file illegibly thanks!
     
  4. I'd recommend creating a new thread instead of asking a new question in a thread from 11 months ago, so you will be more likely to get the help you need.
     
    • Agree Agree x 1
    • Funny Funny x 1