using System; using Vintagestory.API.Common.Entities; using Vintagestory.API.MathTools; namespace AriasServerUtils { [Serializable] public class PlayerPosition { public int X { get; set; } = 0; public int Y { get; set; } = 0; public int Z { get; set; } = 0; public int Dimension { get; set; } = 0; public float Yaw { get; set; } = 0.0f; public void Merge(Entity entity) { entity.TeleportTo(new BlockPos(X, Y, Z, Dimension)); entity.Pos.SetYaw(Yaw); } /// /// Generates a PlayerPosition object using a entity. /// /// A player entity /// PlayerPos snapshot object of the entity public static PlayerPosition from(Entity entity) { PlayerPosition pos = new PlayerPosition(); BlockPos playerPos = entity.Pos.AsBlockPos; pos.X = playerPos.X; pos.Y = playerPos.Y; pos.Z = playerPos.Z; pos.Dimension = playerPos.dimension; pos.Yaw = entity.Pos.Yaw; return pos; } } }