mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
We don't need to store each individual RGB color for maps
This commit is contained in:
parent
67c93dcc8c
commit
6f4d433561
2 changed files with 12 additions and 16 deletions
|
@ -67,7 +67,7 @@ public class JavaMapDataTranslator extends PacketTranslator<ServerMapDataPacket>
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for (byte colorId : data.getData()) {
|
for (byte colorId : data.getData()) {
|
||||||
colors[idx++] = MapColor.fromId(colorId & 0xFF).toARGB();
|
colors[idx++] = MapColor.fromId(colorId & 0xFF).getARGB();
|
||||||
}
|
}
|
||||||
|
|
||||||
mapItemDataPacket.setColors(colors);
|
mapItemDataPacket.setColors(colors);
|
||||||
|
|
|
@ -277,28 +277,24 @@ public enum MapColor {
|
||||||
|
|
||||||
private static final MapColor[] VALUES = values();
|
private static final MapColor[] VALUES = values();
|
||||||
|
|
||||||
private final int red;
|
private final int value;
|
||||||
private final int green;
|
|
||||||
private final int blue;
|
|
||||||
|
|
||||||
MapColor(int red, int green, int blue) {
|
MapColor(int red, int green, int blue) {
|
||||||
this.red = red;
|
int alpha = 255;
|
||||||
this.green = green;
|
if (red == -1 && green == -1 && blue == -1)
|
||||||
this.blue = blue;
|
alpha = 0; // transparent
|
||||||
|
|
||||||
|
this.value = ((alpha & 0xFF) << 24) |
|
||||||
|
((red & 0xFF) << 16) |
|
||||||
|
((green & 0xFF) << 8) |
|
||||||
|
(blue & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapColor fromId(int id) {
|
public static MapColor fromId(int id) {
|
||||||
return id >= 0 && id < VALUES.length ? VALUES[id] : COLOR_0;
|
return id >= 0 && id < VALUES.length ? VALUES[id] : COLOR_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int toARGB() {
|
public int getARGB() {
|
||||||
int alpha = 255;
|
return value;
|
||||||
if (red == -1 && green == -1 && blue == -1)
|
|
||||||
alpha = 0; // transparent
|
|
||||||
|
|
||||||
return ((alpha & 0xFF) << 24) |
|
|
||||||
((red & 0xFF) << 16) |
|
|
||||||
((green & 0xFF) << 8) |
|
|
||||||
(blue & 0xFF);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue