3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-03 08:21:06 +02:00

We don't need to store each individual RGB color for maps

Dieser Commit ist enthalten in:
Camotoy 2021-09-25 15:02:08 -04:00
Ursprung 67c93dcc8c
Commit 6f4d433561
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 12 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -67,7 +67,7 @@ public class JavaMapDataTranslator extends PacketTranslator<ServerMapDataPacket>
int idx = 0;
for (byte colorId : data.getData()) {
colors[idx++] = MapColor.fromId(colorId & 0xFF).toARGB();
colors[idx++] = MapColor.fromId(colorId & 0xFF).getARGB();
}
mapItemDataPacket.setColors(colors);

Datei anzeigen

@ -277,28 +277,24 @@ public enum MapColor {
private static final MapColor[] VALUES = values();
private final int red;
private final int green;
private final int blue;
private final int value;
MapColor(int red, int green, int blue) {
this.red = red;
this.green = green;
this.blue = blue;
int alpha = 255;
if (red == -1 && green == -1 && blue == -1)
alpha = 0; // transparent
this.value = ((alpha & 0xFF) << 24) |
((red & 0xFF) << 16) |
((green & 0xFF) << 8) |
(blue & 0xFF);
}
public static MapColor fromId(int id) {
return id >= 0 && id < VALUES.length ? VALUES[id] : COLOR_0;
}
public int toARGB() {
int alpha = 255;
if (red == -1 && green == -1 && blue == -1)
alpha = 0; // transparent
return ((alpha & 0xFF) << 24) |
((red & 0xFF) << 16) |
((green & 0xFF) << 8) |
(blue & 0xFF);
public int getARGB() {
return value;
}
}