2020-01-07 10:53:42 -05:00
|
|
|
package party._2a03.mc.server;
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
2020-06-24 16:07:12 -04:00
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import net.minecraft.util.registry.Registry;
|
|
|
|
import net.minecraft.util.registry.RegistryKey;
|
2020-01-07 10:53:42 -05:00
|
|
|
import party._2a03.mc.server.Config;
|
|
|
|
|
|
|
|
public class PlayerPosition {
|
|
|
|
public double x;
|
|
|
|
public double y;
|
|
|
|
public double z;
|
|
|
|
public float yaw;
|
|
|
|
public float pitch;
|
2020-06-24 16:07:12 -04:00
|
|
|
public RegistryKey registrykey;
|
2020-01-07 10:53:42 -05:00
|
|
|
|
|
|
|
public PlayerPosition() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public PlayerPosition(JSONArray data) {
|
2020-06-24 16:07:12 -04:00
|
|
|
String registry_string = data.getString(5);
|
|
|
|
if (!registry_string.isEmpty()) {
|
2020-01-07 10:53:42 -05:00
|
|
|
this.x = data.getDouble(0);
|
|
|
|
this.y = data.getDouble(1);
|
|
|
|
this.z = data.getDouble(2);
|
2020-05-29 11:51:31 -04:00
|
|
|
this.yaw = data.getNumber(3).floatValue();
|
|
|
|
this.pitch = data.getNumber(4).floatValue();
|
2020-06-24 16:07:12 -04:00
|
|
|
this.registrykey = RegistryKey.of(Registry.DIMENSION, new Identifier(registry_string));
|
2020-01-07 10:53:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-24 16:07:12 -04:00
|
|
|
public PlayerPosition(double p_x, double p_y, double p_z, float p_yaw, float p_pitch, RegistryKey p_registrykey) {
|
2020-01-07 10:53:42 -05:00
|
|
|
this.x = p_x;
|
|
|
|
this.y = p_y;
|
|
|
|
this.z = p_z;
|
|
|
|
this.yaw = p_yaw;
|
|
|
|
this.pitch = p_pitch;
|
2020-06-24 16:07:12 -04:00
|
|
|
this.registrykey = p_registrykey;
|
2020-01-07 10:53:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public JSONArray getJSON() {
|
|
|
|
JSONArray json = new JSONArray();
|
2020-06-24 16:07:12 -04:00
|
|
|
if (this.registrykey != null) {
|
2020-01-07 10:53:42 -05:00
|
|
|
json.put(this.x);
|
|
|
|
json.put(this.y);
|
|
|
|
json.put(this.z);
|
|
|
|
json.put(this.yaw);
|
|
|
|
json.put(this.pitch);
|
2020-06-24 16:07:12 -04:00
|
|
|
json.put(this.registrykey.getValue().toString());
|
2020-01-07 10:53:42 -05:00
|
|
|
} else {
|
|
|
|
json.put(0);
|
|
|
|
json.put(0);
|
|
|
|
json.put(0);
|
|
|
|
json.put(0);
|
|
|
|
json.put(0);
|
2020-06-24 16:07:12 -04:00
|
|
|
json.put("");
|
2020-01-07 10:53:42 -05:00
|
|
|
}
|
|
|
|
return json;
|
|
|
|
}
|
2020-06-24 16:07:12 -04:00
|
|
|
}
|