}
});
} else if (type == Vector3.class) {
writeActions.add((packet, buffer) -> {
try {
Vector3 vector = (Vector3) field.get(packet);
if (vector != null) {
buffer.writeFloat(vector.getX());
buffer.writeFloat(vector.getY());
buffer.writeFloat(vector.getZ());
} else {
buffer.writeFloat(0);
buffer.writeFloat(0);
buffer.writeFloat(0);
}
} catch (IllegalArgumentException | IllegalAccessException e) {
// should never happen
LOGGER.error("Unexpected error: ", e);
throw new RuntimeException(e);
}
});
} else if (type == Vector4.class) {
writeActions.add((packet, buffer) -> {
try {
Vector4 vector = (Vector4) field.get(packet);
if (vector != null) {
buffer.writeFloat(vector.getX());
buffer.writeFloat(vector.getY());
buffer.writeFloat(vector.getZ());
buffer.writeFloat(vector.getA());
} else {
buffer.writeFloat(0);
buffer.writeFloat(0);
buffer.writeFloat(0);
buffer.writeFloat(0);