1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
@@ -158,14 +158,14 @@ public class CraftMapCanvas implements MapCanvas {
|
||||
x = xStart;
|
||||
y += font.getHeight() + 1;
|
||||
continue;
|
||||
} else if (ch == '\u00A7') {
|
||||
} else if (ch == '§') {
|
||||
int j = text.indexOf(';', i);
|
||||
Preconditions.checkArgument(j >= 0, "text (%s) unterminated color string", text);
|
||||
try {
|
||||
color = Byte.parseByte(text.substring(i + 1, j));
|
||||
i = j;
|
||||
continue;
|
||||
} catch (NumberFormatException ex) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.bukkit.map.MapPalette;
|
||||
|
||||
public class CraftMapColorCache implements MapPalette.MapColorCache {
|
||||
|
||||
private static final String MD5_CACHE_HASH = "E88EDD068D12D39934B40E8B6B124C83";
|
||||
private static final String MD5_CACHE_HASH = "E88EDD068D12D39934B40E8B6B124C83"; // 248 colors
|
||||
private static final File CACHE_FILE = new File("map-color-cache.dat");
|
||||
private byte[] cache;
|
||||
private final Logger logger;
|
||||
@@ -31,10 +31,16 @@ public class CraftMapColorCache implements MapPalette.MapColorCache {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
private static CraftMapColorCache dryRun() {
|
||||
CraftMapColorCache mapColorCache = new CraftMapColorCache(Logger.getGlobal());
|
||||
mapColorCache.cache = new byte[256 * 256 * 256];
|
||||
mapColorCache.buildCache();
|
||||
return mapColorCache;
|
||||
}
|
||||
|
||||
// Builds and prints the md5 hash of the cache, this should be run when new map colors are added to update the MD5_CACHE_HASH string
|
||||
public static void main(String[] args) {
|
||||
CraftMapColorCache craftMapColorCache = new CraftMapColorCache(Logger.getGlobal());
|
||||
craftMapColorCache.buildCache();
|
||||
CraftMapColorCache craftMapColorCache = CraftMapColorCache.dryRun();
|
||||
try {
|
||||
byte[] hash = MessageDigest.getInstance("MD5").digest(craftMapColorCache.cache);
|
||||
System.out.println("MD5_CACHE_HASH: " + CraftMapColorCache.bytesToString(hash));
|
||||
@@ -151,7 +157,7 @@ public class CraftMapColorCache implements MapPalette.MapColorCache {
|
||||
|
||||
@Override
|
||||
public byte matchColor(Color color) {
|
||||
Preconditions.checkState(this.isCached(), "Cache not build jet");
|
||||
Preconditions.checkState(this.isCached(), "Cache not build yet");
|
||||
|
||||
return this.cache[this.toInt(color)];
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.map;
|
||||
import net.minecraft.world.level.saveddata.maps.MapDecoration;
|
||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.map.MapCanvas;
|
||||
import org.bukkit.map.MapCursor;
|
||||
@@ -15,7 +14,7 @@ public class CraftMapRenderer extends MapRenderer {
|
||||
|
||||
private final MapItemSavedData worldMap;
|
||||
|
||||
public CraftMapRenderer(CraftMapView mapView, MapItemSavedData worldMap) {
|
||||
public CraftMapRenderer(MapItemSavedData worldMap) {
|
||||
super(false);
|
||||
this.worldMap = worldMap;
|
||||
}
|
||||
@@ -23,10 +22,8 @@ public class CraftMapRenderer extends MapRenderer {
|
||||
@Override
|
||||
public void render(MapView map, MapCanvas canvas, Player player) {
|
||||
// Map
|
||||
// Paper start - Swap inner and outer loops here to (theoretically) improve cache locality
|
||||
for (int y = 0; y < 128; ++y) {
|
||||
for (int x = 0; x < 128; ++x) {
|
||||
// Paper end
|
||||
canvas.setPixel(x, y, this.worldMap.colors[y * 128 + x]);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +36,7 @@ public class CraftMapRenderer extends MapRenderer {
|
||||
|
||||
for (String key : this.worldMap.decorations.keySet()) {
|
||||
// If this cursor is for a player check visibility with vanish system
|
||||
Player other = Bukkit.getPlayerExact((String) key);
|
||||
Player other = Bukkit.getPlayerExact(key);
|
||||
if (other != null && !player.canSee(other)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ public final class CraftMapView implements MapView {
|
||||
private final Map<CraftPlayer, RenderData> renderCache = new WeakHashMap<>();
|
||||
private final List<MapRenderer> renderers = new ArrayList<>();
|
||||
private final Map<MapRenderer, Map<CraftPlayer, CraftMapCanvas>> canvases = new HashMap<>();
|
||||
protected final MapItemSavedData worldMap;
|
||||
final MapItemSavedData worldMap;
|
||||
|
||||
public CraftMapView(MapItemSavedData worldMap) {
|
||||
this.worldMap = worldMap;
|
||||
this.addRenderer(new CraftMapRenderer(this, worldMap));
|
||||
this.addRenderer(new CraftMapRenderer(worldMap));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,7 +37,7 @@ public final class CraftMapView implements MapView {
|
||||
|
||||
@Override
|
||||
public boolean isVirtual() {
|
||||
return this.renderers.size() > 0 && !(this.renderers.get(0) instanceof CraftMapRenderer);
|
||||
return !this.renderers.isEmpty() && !(this.renderers.get(0) instanceof CraftMapRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user