43 lines
1.3 KiB
Java
43 lines
1.3 KiB
Java
package dev.zontreck.otemod.database;
|
|
|
|
import com.ibm.icu.impl.InvalidFormatException;
|
|
|
|
import dev.zontreck.otemod.containers.Vector2;
|
|
import dev.zontreck.otemod.containers.Vector3;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.nbt.NbtUtils;
|
|
|
|
/**
|
|
* This defines the data structure, and methods for deserializing and serializing teleport destinations, for easier storage in the database
|
|
**/
|
|
public class TeleportDestination {
|
|
public Vector3 Position;
|
|
public Vector2 Rotation;
|
|
public String Dimension;
|
|
|
|
public TeleportDestination(CompoundTag tag) throws InvalidFormatException
|
|
{
|
|
Position = new Vector3(tag.getString("Position"));
|
|
Rotation = new Vector2(tag.getString("Rotation"));
|
|
Dimension = tag.getString("Dimension");
|
|
}
|
|
public TeleportDestination(Vector3 pos, Vector2 rot, String dim)
|
|
{
|
|
Position = pos;
|
|
Rotation = rot;
|
|
Dimension = dim;
|
|
}
|
|
|
|
@Override
|
|
public String toString()
|
|
{
|
|
CompoundTag tag = new CompoundTag();
|
|
tag.putString("Position", Position.toString());
|
|
tag.putString("Rotation", Rotation.toString());
|
|
tag.putString("Dimension", Dimension);
|
|
|
|
return NbtUtils.structureToSnbt(tag);
|
|
|
|
}
|
|
|
|
}
|