package moe.ymc.acron.common; import com.google.gson.*; import com.google.gson.annotations.SerializedName; import java.lang.reflect.Type; public record Vec2f(@SerializedName("x") float x, @SerializedName("y") float y) { public static class Vec2fDeserializer implements JsonDeserializer { @Override public Vec2f deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { final JsonObject object = json.getAsJsonObject(); final float x = object.has("x") ? object.get("x").getAsFloat() : 0.0f; final float y = object.has("y") ? object.get("y").getAsFloat() : 0.0f; return new Vec2f(x, y); } } }