using System; using System.Collections.Generic; using Vintagestory.API.Common; 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 float Pitch { get; set; } = 0.0f; public static readonly PlayerPosition ZERO = new(0, 0, 0, 0, 0.0f, 0.0f); public PlayerPosition() { } internal PlayerPosition(int x, int y, int z, int dim, float yaw, float pitch) { this.X = x; this.Y = y; this.Z = z; this.Dimension = dim; this.Yaw = yaw; this.Pitch = pitch; } public void Merge(Entity entity) { entity.TeleportTo(new BlockPos(X, Y, Z, Dimension)); entity.Pos.SetYaw(Yaw); entity.Pos.Pitch = Pitch; } /// /// 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; pos.Pitch = entity.Pos.Pitch; return pos; } public PlayerPosition Clone() { return new PlayerPosition(this.X, this.Y, this.Z, this.Dimension, this.Yaw, this.Pitch); } } public class PlayerInventory { public List Items = new List(); } /// /// This class creates a simple storage for all memory within this mod /// [Serializable] public class PlayerStorage { public Dictionary Homes = new Dictionary(); } /// /// This class represents a single home object /// [Serializable] public class Home { public PlayerPosition Location { get; set; } public static Home MakeHome(Entity player, string homeName) { Home home = new Home(); home.Location = PlayerPosition.from(player); return home; } } }