Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-09 01:50:05 +01:00
Improve MarkerData serialization logic
Dieser Commit ist enthalten in:
Ursprung
d066e2d424
Commit
af0b6fc48d
@ -30,10 +30,9 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
|
||||
byte flags = friendlyByteBuf.readByte();
|
||||
|
||||
if ((flags & 1) != 0) {
|
||||
if (flags != 0) {
|
||||
minRegion = friendlyByteBuf.readVec3();
|
||||
maxRegion = friendlyByteBuf.readVec3();
|
||||
}
|
||||
|
||||
if ((flags & 2) != 0) {
|
||||
lineArgb = friendlyByteBuf.readInt();
|
||||
@ -46,6 +45,7 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
if ((flags & 8) != 0) {
|
||||
faceArgb = friendlyByteBuf.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
return new MarkerData(uuid, position, name, minRegion, maxRegion, lineArgb, lineThickness, faceArgb);
|
||||
}
|
||||
@ -57,34 +57,19 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
friendlyByteBuf.writeDouble(markerData.position.z);
|
||||
friendlyByteBuf.writeNullable(markerData.name, FriendlyByteBuf::writeUtf);
|
||||
|
||||
byte flags = 0;
|
||||
|
||||
if (markerData.minRegion != null && markerData.maxRegion != null) {
|
||||
flags |= 1;
|
||||
}
|
||||
|
||||
if (markerData.lineArgb != 0) {
|
||||
flags |= 2;
|
||||
}
|
||||
|
||||
if (markerData.lineThickness != 0) {
|
||||
flags |= 4;
|
||||
}
|
||||
|
||||
if (markerData.faceArgb != 0) {
|
||||
flags |= 8;
|
||||
}
|
||||
|
||||
byte flags = 1;
|
||||
if (markerData.lineArgb != 0) flags |= 2;
|
||||
if (markerData.lineThickness != 0) flags |= 4;
|
||||
if (markerData.faceArgb != 0) flags |= 8;
|
||||
friendlyByteBuf.writeByte(flags);
|
||||
|
||||
if (markerData.minRegion != null && markerData.maxRegion != null) {
|
||||
friendlyByteBuf.writeDouble(markerData.minRegion.x);
|
||||
friendlyByteBuf.writeDouble(markerData.minRegion.y);
|
||||
friendlyByteBuf.writeDouble(markerData.minRegion.z);
|
||||
friendlyByteBuf.writeDouble(markerData.maxRegion.x);
|
||||
friendlyByteBuf.writeDouble(markerData.maxRegion.y);
|
||||
friendlyByteBuf.writeDouble(markerData.maxRegion.z);
|
||||
}
|
||||
|
||||
if (markerData.lineArgb != 0) {
|
||||
friendlyByteBuf.writeInt(markerData.lineArgb);
|
||||
@ -97,6 +82,9 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
if (markerData.faceArgb != 0) {
|
||||
friendlyByteBuf.writeInt(markerData.faceArgb);
|
||||
}
|
||||
} else {
|
||||
friendlyByteBuf.writeByte(0);
|
||||
}
|
||||
}
|
||||
|
||||
private static final Field dataField;
|
||||
@ -148,9 +136,6 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
double maxZ = max.getDouble(2);
|
||||
minRegion = new Vec3(minX, minY, minZ);
|
||||
maxRegion = new Vec3(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (data.contains("line_argb", Tag.TAG_ANY_NUMERIC)) {
|
||||
lineArgb = data.getInt("line_argb");
|
||||
@ -163,6 +148,8 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
if (data.contains("face_argb", Tag.TAG_ANY_NUMERIC)) {
|
||||
faceArgb = data.getInt("face_argb");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new MarkerData(marker.getUUID(), position, name, minRegion, maxRegion, lineArgb, lineThickness, faceArgb);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren