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; 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(); JSONObject ret = new JSONObject();
ret.put("text", message); ret.put("text", message);
if (color != null) { if (color != null) {

View File

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