Add spawn related commands and data storage system

This commit is contained in:
zontreck 2025-01-18 02:59:24 -07:00
parent f2a23552af
commit 0f318a9efa
7 changed files with 211 additions and 9 deletions

View file

@ -0,0 +1,45 @@
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);
}
/// <summary>
/// Generates a PlayerPosition object using a entity.
/// </summary>
/// <param name="entity">A player entity</param>
/// <returns>PlayerPos snapshot object of the entity</returns>
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;
}
}
}