Spawn map in item frame

Discussion in 'Plugin Development' started by Nogtail, Dec 1, 2013.

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

    Nogtail

    I know how to write an image to a map using the MapInitializeEvent but not sure how to go about getting the map if it was spawned in in an item frame.

    Thanks.

    Bump.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  2. Offline

    Nogtail

    bump.
     
  3. Offline

    xTrollxDudex

    Nogtail
    PHP:
    World world Bukkit.getServer().getWorld("Your world here");
    MapView map Bukkit.getServer().createMap(world);
     
    ItemFrame itemFrame = (ItemFrameworld.spawn(/* location */ItemFrame.class);
    itemFrame.setRotation(/* Rotation.SOMETHING */);
    itemFrame.setItem(new ItemStack(Material.MAP1map.getId())); //WARNING: This is depracated
     
  4. Offline

    Nogtail

    Thanks for the reply :), I have been reading that there is only 65,536 possible maps, would you know if there is any way to increase that number or what would happen if that number is reached, thanks :)
     
  5. Offline

    xTrollxDudex

    Nogtail
    Hmm. I think you'd get bad luck forever and a virus will DDoS your computer then make an electrical charge surge through your neighborhood. Of course, this is best case scenario ;)
     
    Nogtail likes this.
  6. Offline

    JRL1004

  7. Offline

    xTrollxDudex

    I wouldn't imagine it :O
     
  8. Offline

    Nogtail

    Lol, but in all seriousness what happens? I assume it just loops back to map one or something or tries to make negitive map numbers.
     
  9. Offline

    desht

    Haven't looked at the server source for this, but I would expect server.createMap() to simply fail (null return?) if all available map ID's have been used up. In any case, don't count on any useful results. And definitely don't just create a new map every time your plugin starts up - track the ID you get the first time and re-use that on next startup.

    The map ID is currently tied to map item durability value, which is a short - therefore there is a max of 65536 distinct maps available. The server does keep track of what's been allocated - you can check this on your server by looking in <server-dir>/<world-name>/data - you'll see a file call idcounts.dat and zero or more map_<N>.dat files - idcounts.dat tracks the latest map ID that was allocated. See http://minecraft.gamepedia.com/Map_item_format for more info.

    The association between map ID and item durability may go away soon - this is why any Bukkit methods which refer to numeric (short) map ID's are now deprecated.
     
Thread Status:
Not open for further replies.

Share This Page