Refactor vector system to be cleaner

- Move Vector, etc. into `.math` package
- Drop many methods that will be auto-promoted anyways, eg. with
`divide(int)` and `divide(double)` the first is now gone.
- Take Block vectors into their own class hierarchy
- Make it clear throughout the API what takes blockvectors
- many more improvements
This commit is contained in:
Kenzie Togami
2018-10-14 03:40:53 -07:00
parent d7c528247b
commit 399e0ad5fa
230 changed files with 4216 additions and 3913 deletions

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.util.gson;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.math.Vector3;
/**
* Utility methods for Google's GSON library.
@ -38,7 +38,7 @@ public final class GsonUtil {
*/
public static GsonBuilder createBuilder() {
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(Vector.class, new VectorAdapter());
gsonBuilder.registerTypeAdapter(Vector3.class, new VectorAdapter());
return gsonBuilder;
}

View File

@ -24,17 +24,17 @@ import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.math.Vector3;
import java.lang.reflect.Type;
/**
* Deserializes {@code Vector}s for GSON.
*/
public class VectorAdapter implements JsonDeserializer<Vector> {
public class VectorAdapter implements JsonDeserializer<Vector3> {
@Override
public Vector deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
public Vector3 deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonArray jsonArray = json.getAsJsonArray();
if (jsonArray.size() != 3) {
throw new JsonParseException("Expected array of 3 length for Vector");
@ -44,6 +44,6 @@ public class VectorAdapter implements JsonDeserializer<Vector> {
double y = jsonArray.get(1).getAsDouble();
double z = jsonArray.get(2).getAsDouble();
return new Vector(x, y, z);
return new Vector3(x, y, z);
}
}