This repository has been archived on 2024-07-25. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Thresholds/src/main/java/dev/zontreck/otemod/database/TeleportDestination.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);
}
}