How to get location of all generated structures in 1.13

Discussion in 'Spigot Plugin Development' started by Corwin, Aug 10, 2018 at 10:20 AM.

  1. I would like to get list of locations of every generated structure on map, like endcities, strongholts, ocean monuments etc.

    prior to 1.13 server generated files like Monument.dat, Stronghold.dat, EndCity.dat in map data folder.
    i used to load these generaly small files and parse NBT structures out of them to get the locations and info about structures. usualy few hundreds of kilobytes of data to process.

    since 1.13 those files are not generated standalone, data about structures is part of region files. this means that to get locations as before, i would need to load and process whole map (all region files, hundreds of megabytes/gigabytes of data).

    anyone have idea how to get structure locations any other way?
  2. I would assume there is a way of doing this through NMS, some per world list of structures maybe, but I've not dug into this stuff myself.
  3. This thread: Getting a villager's village has some interesting info on getting villages using NMS which should get you part way there... at least for end cities?
    #3 eccentric, Aug 12, 2018 at 4:08 AM
    Last edited: Aug 12, 2018 at 4:16 AM
  4. that thread is about villages in overworld... it helps, but not usable for End worlds.

    i see few classes in NMS that describe generated structures including EndCity... just no idea how to get list of them yet
  5. This seems rather tricky - it almost seems like they are not even stored anywhere. If you haven't already, you can take a look at StructureGenerator class (specifically 'getNearestGeneratedFeature()') -- by following the method calls, you'll see that there is a cache, but not a permanent one. ChunkGeneratorAbstract, in which the 'getStructureStartCache()' is located, returns an expiring map and does not save it at any point.

    Now, where do you need this? Maybe there's another way to achieve what you want?
  6. what used to be content of file like EndCity.dat (describing every endcity generated on whole map) is since 1.13 moved to individual region files (.mca), each region file contains info about structures it contains

    Main goal is, when End map gets wiped and regenerated, get location of every endcity and turn it to individual maps(like Treasure maps in overworld), showing location of the city, so it can be sold by villagers.

    in previous versions my plugin processed the EndCity.dat (file size between 30-100kb), and processed locations to map given to villager inventory.
    in 1.13 this approach would mean loading every .mca file to parse Structures nbt tag out of it... which mean few hundreds files, each ~4mb each.
    and i don't feel like doing that in plugin is good idea.

    (another idea would be download the map and process it offline but i would prefer automated process. and since minecraft server is on shared host, i cannot run any apps directly on server)
  7. Yeah, look into the NMS code to see how Minecraft keeps track of it. And don't use the decompiled spigot.jar, use the MCP decompilation since that's a lot better to read.

Share This Page