wip maps (1.8+)

This commit is contained in:
Bixilon 2020-06-28 00:06:40 +02:00
parent bf4bb5992b
commit 18ce9d73c8
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 30 additions and 11 deletions

View File

@ -108,7 +108,7 @@ public class TextComponent {
this.json = json;
}
private JSONObject getExtraByAttributes(String message, ChatAttributes color, List<ChatAttributes> formatting) {
private static JSONObject getExtraByAttributes(String message, ChatAttributes color, List<ChatAttributes> formatting) {
JSONObject ret = new JSONObject();
ret.put("text", message);
if (color != null) {

View File

@ -34,7 +34,7 @@ public class PacketMapData implements ClientboundPacket {
byte[] colors;
// players
List<MapPlayerSet> players;
List<MapPinSet> pins;
//scale
byte scale;
@ -55,15 +55,15 @@ public class PacketMapData implements ClientboundPacket {
colors = buffer.readBytes(length - 3); // 3: dataData(1) + xStart (1) + yStart (1)
break;
case PLAYERS:
players = new ArrayList<>();
pins = new ArrayList<>();
length--; // minus the dataData
for (int i = 0; i < length / 3; i++) { // loop over all sets ( 1 set: 3 bytes)
byte data = buffer.readByte();
byte type = BitByte.getLow4Bits(data);
MapPlayerDirection direction = MapPlayerDirection.byId(BitByte.getHigh4Bits(data));
byte x = buffer.readByte();
byte y = buffer.readByte();
players.add(new MapPlayerSet(type, direction, x, y));
byte z = buffer.readByte();
pins.add(new MapPinSet(type, direction, x, z));
}
break;
case SCALE:
@ -72,7 +72,26 @@ public class PacketMapData implements ClientboundPacket {
}
break;
case VERSION_1_8:
//ToDo
mapId = buffer.readVarInt();
scale = buffer.readByte();
int pinCount = buffer.readVarInt();
pins = new ArrayList<>();
for (int i = 0; i < pinCount; i++) {
byte directionAndType = buffer.readByte();
byte x = buffer.readByte();
byte z = buffer.readByte();
pins.add(new MapPinSet(BitByte.getHigh4Bits(directionAndType), MapPlayerDirection.byId(BitByte.getLow4Bits(directionAndType)), x, z));
}
byte columns = buffer.readByte();
if (columns > 0) {
byte rows = buffer.readByte();
byte xOffset = buffer.readByte();
byte zOffset = buffer.readByte();
int dataLength = buffer.readVarInt();
byte[] data = buffer.readBytes(dataLength);
}
break;
}
}
@ -104,10 +123,10 @@ public class PacketMapData implements ClientboundPacket {
}
public List<MapPlayerSet> getPlayers() {
return players;
public List<MapPinSet> getPins() {
return pins;
}
public byte getScale() {
return scale;
@ -163,13 +182,13 @@ public class PacketMapData implements ClientboundPacket {
}
}
public static class MapPlayerSet {
public static class MapPinSet {
final int type;
final MapPlayerDirection direction;
byte x;
byte z;
public MapPlayerSet(int type, MapPlayerDirection direction, byte x, byte z) {
public MapPinSet(int type, MapPlayerDirection direction, byte x, byte z) {
this.type = type;
this.direction = direction;
this.x = x;