Move JavaResourcePackConverter to its own cs proj

This commit is contained in:
miku-666
2026-02-07 09:30:27 +01:00
parent 4232f258c3
commit 8acec4cdde
23 changed files with 188 additions and 56 deletions

View File

@@ -0,0 +1,24 @@
using System;
using System.Drawing;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JavaResourcePackConverter
{
public class PointJsonConverter : JsonConverter<Point>
{
public override void WriteJson(JsonWriter writer, Point value, JsonSerializer serializer)
{
JObject jo = new JObject();
jo.Add("x", value.X);
jo.Add("y", value.Y);
jo.WriteTo(writer);
}
public override Point ReadJson(JsonReader reader, Type objectType, Point existingValue, bool hasExistingValue, JsonSerializer serializer)
{
JObject jo = JObject.Load(reader);
return new Point((int)(jo["x"] ?? 0), (int)(jo["y"] ?? 0));
}
}
}