Mirror von
https://github.com/Moulberry/AxiomPaperPlugin.git
synchronisiert 2024-11-08 17:40:04 +01:00
Add support for line_argb, line_thickness and face_argb
Dieser Commit ist enthalten in:
Ursprung
b3f6842c91
Commit
d066e2d424
@ -15,20 +15,39 @@ import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.UUID;
|
||||
|
||||
public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nullable Vec3 minRegion, @Nullable Vec3 maxRegion) {
|
||||
public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nullable Vec3 minRegion, @Nullable Vec3 maxRegion,
|
||||
int lineArgb, float lineThickness, int faceArgb) {
|
||||
public static MarkerData read(FriendlyByteBuf friendlyByteBuf) {
|
||||
UUID uuid = friendlyByteBuf.readUUID();
|
||||
Vec3 position = new Vec3(friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble());
|
||||
Vec3 position = friendlyByteBuf.readVec3();
|
||||
String name = friendlyByteBuf.readNullable(FriendlyByteBuf::readUtf);
|
||||
|
||||
Vec3 minRegion = null;
|
||||
Vec3 maxRegion = null;
|
||||
if (friendlyByteBuf.readBoolean()) {
|
||||
minRegion = new Vec3(friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble());
|
||||
maxRegion = new Vec3(friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble());
|
||||
int lineArgb = 0;
|
||||
float lineThickness = 0;
|
||||
int faceArgb = 0;
|
||||
|
||||
byte flags = friendlyByteBuf.readByte();
|
||||
|
||||
if ((flags & 1) != 0) {
|
||||
minRegion = friendlyByteBuf.readVec3();
|
||||
maxRegion = friendlyByteBuf.readVec3();
|
||||
}
|
||||
|
||||
return new MarkerData(uuid, position, name, minRegion, maxRegion);
|
||||
if ((flags & 2) != 0) {
|
||||
lineArgb = friendlyByteBuf.readInt();
|
||||
}
|
||||
|
||||
if ((flags & 4) != 0) {
|
||||
lineThickness = friendlyByteBuf.readFloat();
|
||||
}
|
||||
|
||||
if ((flags & 8) != 0) {
|
||||
faceArgb = friendlyByteBuf.readInt();
|
||||
}
|
||||
|
||||
return new MarkerData(uuid, position, name, minRegion, maxRegion, lineArgb, lineThickness, faceArgb);
|
||||
}
|
||||
|
||||
public static void write(FriendlyByteBuf friendlyByteBuf, MarkerData markerData) {
|
||||
@ -38,16 +57,45 @@ 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;
|
||||
}
|
||||
|
||||
friendlyByteBuf.writeByte(flags);
|
||||
|
||||
if (markerData.minRegion != null && markerData.maxRegion != null) {
|
||||
friendlyByteBuf.writeBoolean(true);
|
||||
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);
|
||||
} else {
|
||||
friendlyByteBuf.writeBoolean(false);
|
||||
}
|
||||
|
||||
if (markerData.lineArgb != 0) {
|
||||
friendlyByteBuf.writeInt(markerData.lineArgb);
|
||||
}
|
||||
|
||||
if (markerData.lineArgb != 0) {
|
||||
friendlyByteBuf.writeFloat(markerData.lineThickness);
|
||||
}
|
||||
|
||||
if (markerData.faceArgb != 0) {
|
||||
friendlyByteBuf.writeInt(markerData.faceArgb);
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,6 +131,10 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
|
||||
Vec3 minRegion = null;
|
||||
Vec3 maxRegion = null;
|
||||
int lineArgb = 0;
|
||||
float lineThickness = 0;
|
||||
int faceArgb = 0;
|
||||
|
||||
if (data.contains("min", Tag.TAG_LIST) && data.contains("max", Tag.TAG_LIST)) {
|
||||
ListTag min = data.getList("min", Tag.TAG_DOUBLE);
|
||||
ListTag max = data.getList("max", Tag.TAG_DOUBLE);
|
||||
@ -100,6 +152,18 @@ public record MarkerData(UUID uuid, Vec3 position, @Nullable String name, @Nulla
|
||||
|
||||
}
|
||||
|
||||
return new MarkerData(marker.getUUID(), position, name, minRegion, maxRegion);
|
||||
if (data.contains("line_argb", Tag.TAG_ANY_NUMERIC)) {
|
||||
lineArgb = data.getInt("line_argb");
|
||||
}
|
||||
|
||||
if (data.contains("line_thickness", Tag.TAG_ANY_NUMERIC)) {
|
||||
lineThickness = data.getInt("line_thickness");
|
||||
}
|
||||
|
||||
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