generated from AriasCreations/vsmodtemplate
45 lines
No EOL
1.2 KiB
C#
45 lines
No EOL
1.2 KiB
C#
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;
|
|
}
|
|
}
|
|
} |