mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-07 10:36:41 +01:00
Add Position JsonAdapter for [x,y,z] format
Also add serializers for existing JsonAdapters
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package emu.grasscutter.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.github.davidmoten.rtreemulti.geometry.Point;
|
||||
@@ -22,9 +23,7 @@ public class Position implements Serializable {
|
||||
@SerializedName(value="z", alternate={"_z", "Z"})
|
||||
@Getter @Setter private float z;
|
||||
|
||||
public Position() {
|
||||
|
||||
}
|
||||
public Position() {}
|
||||
|
||||
public Position(float x, float y) {
|
||||
set(x, y);
|
||||
@@ -34,6 +33,20 @@ public class Position implements Serializable {
|
||||
set(x, y, z);
|
||||
}
|
||||
|
||||
public Position(List<Float> xyz) {
|
||||
switch (xyz.size()) {
|
||||
default: // Might want to error on excess elements, but maybe we want to extend to 3+3 representation later.
|
||||
case 3:
|
||||
this.z = xyz.get(2); // Fall-through
|
||||
case 2:
|
||||
this.y = xyz.get(1); // Fall-through
|
||||
case 1:
|
||||
this.y = xyz.get(0); // pointless fall-through
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public Position(String p) {
|
||||
String[] split = p.split(",");
|
||||
if (split.length >= 2) {
|
||||
|
||||
Reference in New Issue
Block a user