Possibility of creating a MapView at a specific ID?

Discussion in 'Plugin Development' started by Cirno, Mar 14, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    The current given methods for creating maps only creates the map at the next ID. This can be troublesome as some people might want to create maps at a specific ID (i.e they want to use map ID 1337 for their new fancy base) and I was wondering if there was a way (NMS/OBC hackery is fine) to create a MapView for a specific ID.

    edit: Thank you, @xTrollxDudex ; I didn't want to bump this post, but you got me on the right track. I didn't exactly follow all the way to PersistentCollection, but I did manage to just create an instance of WorldMap and registering it via World.a(String, PersistentBase)
    Last edited: Mar 17, 2015
  2. Offline


    Lets walk through the process of creating a map:

    Plugin calls Bukkit#createMap(World)
    CraftServer calls ItemWorldMap#getSavedMap(ItemStack,World)
    The data for the item stack is set by World#b(String)
    World calls

    Here, is where the ID is set. All map IDs are set to the item data, and the item data eventually is set by the integer (short, actually) returne from PersistentBase.

    To override the incremental function, you can replace the "worldMaps" field in NMS World.java, the a(String):int method.

    (By the way, PersistentCollection works by retrieving the key named "map" passed in from ItemWorldMap. The first map will by ID 0, since the value is null. However, the subsequent invocations of the method would observe that the value is NOT null, so the stored short is incremented)
Thread Status:
Not open for further replies.

Share This Page