ViaRewind

ViaRewind

7.4k Downloads

Maps not rendering on 1.8.x[-]

ChefMC opened this issue ยท 2 comments

commented

What is the output url of /viaversion dump?

https://dump.viaversion.com/40e21eec24198edfe97c469fabdfb1087b3d6a503e43b3bfdd5335b754788fc4

How/when does this error happen? login?:

On map rendering. With ProtocolSupport it works fine, the problem only with ViaVersion[Backwards?]. Code:

public void drawMap(boolean updatePictureOnMap) {
	Player p = Bukkit.getPlayerExact(name);
	if (updatePictureOnMap) {
		removeMapCache(p.getName());
	} else {
		ItemStack scheme = new ItemStack(Material.MAP);
		MapView mapView = Bukkit.createMap(p.getWorld());

		for (MapRenderer mapRenderer : mapView.getRenderers()) {
			mapView.removeRenderer(mapRenderer);
		}

		mapView.getRenderers().clear();
		mapView.addRenderer(Utils.plugin.renderer);
		mapView.setScale(Scale.FARTHEST);
		mapView.setUnlimitedTracking(false);
		scheme.setDurability(mapView.getId());
		Protocol type = Utils.plugin.protocol;
		if ((type == Protocol.VIA_VERSION && (int)Via.getAPI().getPlayerVersion(p) <= 47) || (type == Protocol.PROTOCOL_SUPPORT && ProtocolSupportAPI.getProtocolVersion(p).isBefore(ProtocolVersion.MINECRAFT_1_9))) {
			p.getInventory().addItem(scheme);
			p.getInventory().setHeldItemSlot(0);
		} else {
			p.getInventory().setItemInOffHand(scheme);
		}
	}
}

public void removeMapCache(String name) {
	if (Utils.plugin.renderer.playersCached.contains(name))
		Utils.plugin.renderer.playersCached.remove(name);
}

Utils.plugin.renderer is class:

package ru.onlymc.onlybingo;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;

public class Renderer extends MapRenderer {
	List<String> playersCached = new ArrayList<String>();

	@Override
	public void render(MapView mapView, MapCanvas mapCanvas, Player p) {
		Bukkit.getScheduler().runTask(Utils.plugin, new Runnable() {
			@Override
			public void run() {
				if (playersCached.contains(p.getName())) return;
				try {
					playersCached.add(p.getName());
					Utils.plugin.debug("drawImage for: " + p.getName());
					mapCanvas.drawImage(0, 0, ImageIO.read(new URL("http://a.onlymc.ru/mc/bingo/gridl.png")));
				} catch (MalformedURLException e) {
					p.sendMessage(Utils.plugin.prefix + "Error drawing map (MUE)");
					e.printStackTrace();
				} catch (IOException e) {
					p.sendMessage(Utils.plugin.prefix + "Error drawing map (IOE)");
					e.printStackTrace();
				} catch (Exception e) {
					p.sendMessage(Utils.plugin.prefix + "Error drawing map (E)");
					e.printStackTrace();
				}
			}
		});
	}
}

Is there an error in the console? Use pastebin.com. Is there a kick message?:

No

commented

Could you try using the latest development build of ViaBackwards? The map colors added in 1.12 were not being rewritten in previous versions.

commented

Yes, I tried now. Map is drawing,

but drawing once. So when it redrawing, it seems not applied to actual map in hand.