Correctly send BGR over the network for map colors

This commit is contained in:
rtm516 2024-12-22 03:33:29 +00:00
parent 1f167f7cac
commit 29113cea71
No known key found for this signature in database
GPG key ID: 331715B8B007C67A
2 changed files with 8 additions and 4 deletions

View file

@ -285,16 +285,20 @@ public enum MapColor {
alpha = 0; // transparent alpha = 0; // transparent
this.value = ((alpha & 0xFF) << 24) | this.value = ((alpha & 0xFF) << 24) |
((red & 0xFF) << 16) | ((blue & 0xFF) << 16) |
((green & 0xFF) << 8) | ((green & 0xFF) << 8) |
(blue & 0xFF); (red & 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 getARGB() { /**
* Get the ABGR value of the color, bedrock uses this over the network
* @return the int value of the color
*/
public int getABGR() {
return value; return value;
} }
} }

View file

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