Solved Fixing custom maps for 1.13

Discussion in 'Plugin Development' started by The_Spaceman, Aug 6, 2018.

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

    The_Spaceman

    When I try my for 1.12 working custom map code in minecraft 1.13 this doesn't work.

    I get something like white squares and it gets instantly updated to a normal map. In a ItemFrame it gets updated when I lose my sight of the map

    And when I relogged on my server the white squares doesn't appear anymore, but it is staying blank for 1 second and then I see just regulair world...

    Code:
    @Override
    public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
        MapRenderer renderer = mapCanvas.getMapView().getRenderers().get(0);
        if (renderer instanceof ImageMapRenderer) {
            ImageMapRenderer mapRenderer = (ImageMapRenderer) renderer;
            mapCanvas.drawImage(xOffset, yOffset, image);
        }
    }
    
    This is some of my code that represents the working principle of the custom map.
     
  2. Offline

    Zombie_Striker

    @The_Spaceman
    Have you reported this bug to spigot yet? This is most likely a bug on their end.
     
  3. Offline

    Syd

    I didn't encounter any renderer related problems when updating my map-based plugins to 1.13, so this seems odd.

    Something I noticed in your code is, that you're checking in the renderer whether the primary renderer of the rendered map is a certain type of renderer. That seems like it's most likely redundant (unless you have a reason for it).

    Are you removing the vanilla renderer when creating the map?
     
  4. Offline

    The_Spaceman

    1: I check if its is my custom renderer for when other people are using my code in their plugin and use their own renderes as well, so thats why I check (not really necessary, I know).

    2: yes
    Code:
    ItemStack is = new ItemStack(Material.FILLED_MAP);
    
    MapView view = Bukkit.getMap(is.getDurability());
    for (MapRenderer m : view.getRenderers()) {
        view.removeRenderer(m);
    }
    
    try {
        view.addRenderer(new ImageMapRenderer(ImageIO.read(new File("D:\\Users\\jphbo\\Minecraft servers\\test server\\plugins\\maps\\water.jpg"))));
    } catch (IOException e) {
        e.printStackTrace();
    }
    player.getInventory().addItem(is);
    
    this is some code I wrote because my main code didn't work. So I wanted to check that out, this is the code that is the important piece thats adds the custom image to the map.
    It has worked before
     
  5. Offline

    Syd

    Code:
    MapView view = Bukkit.getMap(is.getDurability());
    I think here could be a problem. Using damage values/durability to get the MapID is not valid in 1.13 anymore.

    You have to use
    Code:
    ((MapMeta) is.getItemMeta()).getMapId()
    to get a map item's ID. But since you never set a map ID it should be 0 anyways...

    You probably should try to create a map server-side first, instead of just creating an item. Use the Bukkit.createMap(World) for that. It will return a MapView that you can get it's MapId from to create an item like this
    Code:
    ItemStack item = new ItemStack(Material.FILLED_MAP);
    MapMeta meta = (MapMeta) item.getItemMeta();
    meta.setMapId(mapId);
    item.setItemMeta(meta);
     
  6. Offline

    The_Spaceman

    My org.bukkit.inventory.meta.MapMeta doesn't have the .setMapID method...
    And org.bukkit.map.MapView getID is deprecated.
     
  7. Offline

    Syd

  8. Offline

    The_Spaceman

Thread Status:
Not open for further replies.

Share This Page