Class EntityPos
- Namespace
- Vintagestory.API.Common.Entities
- Assembly
- VintagestoryAPI.dll
Represents all positional information of an entity, such as coordinates, motion and angles
[ProtoContract]
public class EntityPos
- Inheritance
-
EntityPos
- Derived
- Inherited Members
- Extension Methods
Constructors
EntityPos()
public EntityPos()
EntityPos(double, double, double, float, float, float)
public EntityPos(double x, double y, double z, float heading = 0, float pitch = 0, float roll = 0)
Parameters
Fields
Dimension
[ProtoMember(4)]
public int Dimension
Field Value
HeadPitch
The pitch of the agents head
[ProtoMember(10)]
public float HeadPitch
Field Value
HeadYaw
The yaw of the agents head
[ProtoMember(9)]
public float HeadYaw
Field Value
Motion
[ProtoMember(11)]
public Vec3d Motion
Field Value
pitch
[ProtoMember(7)]
protected float pitch
Field Value
roll
[ProtoMember(5)]
protected float roll
Field Value
stance
[ProtoMember(8)]
protected int stance
Field Value
x
[ProtoMember(1)]
protected double x
Field Value
y
[ProtoMember(2)]
protected double y
Field Value
yaw
[ProtoMember(6)]
protected float yaw
Field Value
z
[ProtoMember(3)]
protected double z
Field Value
Properties
AsBlockPos
Returns the position as BlockPos object
public BlockPos AsBlockPos { get; }
Property Value
DimensionYAdjustment
public virtual int DimensionYAdjustment { get; }
Property Value
InternalY
public virtual double InternalY { get; }
Property Value
Pitch
The rotation around the Z axis, in radians.
public virtual float Pitch { get; set; }
Property Value
Roll
The rotation around the X axis, in radians.
public virtual float Roll { get; set; }
Property Value
X
The X position of the Entity.
public virtual double X { get; set; }
Property Value
XYZ
Returns the position as a Vec3d object. Note, dimension aware
public Vec3d XYZ { get; }
Property Value
XYZFloat
Returns the position as a Vec3f object
public Vec3f XYZFloat { get; }
Property Value
XYZInt
Returns the position as a Vec3i object
public Vec3i XYZInt { get; }
Property Value
Y
The Y position of the Entity.
public virtual double Y { get; set; }
Property Value
Yaw
The rotation around the Y axis, in radians.
public virtual float Yaw { get; set; }
Property Value
Z
The Z position of the Entity.
public virtual double Z { get; set; }
Property Value
Methods
Add(double, double, double)
Adds given position offset
public EntityPos Add(double x, double y, double z)
Parameters
Returns
- EntityPos
Returns itself
Add(Vec3f)
Adds given position offset
public EntityPos Add(Vec3f vec)
Parameters
vec
Vec3f
Returns
- EntityPos
Returns itself
AheadCopy(double)
Returns a new entity position that is in front of the position the entity is currently looking at
public EntityPos AheadCopy(double offset)
Parameters
offset
double
Returns
BasicallySameAs(EntityPos, double)
Makes a "basiclly equals" check on the position, motions and angles using a small tolerance of epsilon=0.0001f
public bool BasicallySameAs(EntityPos pos, double epsilon = 0.0001)
Parameters
Returns
BasicallySameAsIgnoreAngles(EntityPos, double)
Makes a "basiclly equals" check on position and motions using a small tolerance of epsilon=0.0001f. Ignores the entities angles.
public bool BasicallySameAsIgnoreAngles(EntityPos pos, double epsilon = 0.0001)
Parameters
Returns
BasicallySameAsIgnoreMotion(EntityPos, double)
Makes a "basiclly equals" check on the position, motions and angles using a small tolerance of epsilon=0.0001f. Ignores motion
public bool BasicallySameAsIgnoreMotion(EntityPos pos, double epsilon = 0.0001)
Parameters
Returns
BehindCopy(double)
Returns a new entity position that is behind of the position the entity is currently looking at
public EntityPos BehindCopy(double offset)
Parameters
offset
double
Returns
Copy()
Creates a full copy
public EntityPos Copy()
Returns
DistanceTo(EntityPos)
public double DistanceTo(EntityPos pos)
Parameters
pos
EntityPos
Returns
DistanceTo(Vec3d)
public double DistanceTo(Vec3d pos)
Parameters
pos
Vec3d
Returns
FromBytes(BinaryReader)
Deserializes all positional information. Does not read HeadYaw and HeadPitch
public void FromBytes(BinaryReader reader)
Parameters
reader
BinaryReader
GetViewVector()
Same as AheadCopy(1) - AheadCopy(0)
public Vec3f GetViewVector()
Returns
GetViewVector(float, float)
Same as AheadCopy(1) - AheadCopy(0)
public static Vec3f GetViewVector(float pitch, float yaw)
Parameters
Returns
HorDistanceTo(EntityPos)
public double HorDistanceTo(EntityPos pos)
Parameters
pos
EntityPos
Returns
HorDistanceTo(Vec3d)
public double HorDistanceTo(Vec3d pos)
Parameters
pos
Vec3d
Returns
HorizontalAheadCopy(double)
Returns a new entity position that is in front of the position the entity is currently looking at using only the entities yaw, meaning the resulting coordinate will be always at the same y position.
public EntityPos HorizontalAheadCopy(double offset)
Parameters
offset
double
Returns
InHorizontalRangeOf(int, int, float)
Returns true if the entity is within given distance of given position
public bool InHorizontalRangeOf(int x, int z, float squareDistance)
Parameters
Returns
InRangeOf(double, double, double, float)
Returns true if the entity is within given distance of given position
public bool InRangeOf(double x, double y, double z, float squareDistance)
Parameters
Returns
InRangeOf(int, int, int, float)
Returns true if the entity is within given distance of given position
public bool InRangeOf(int x, int y, int z, float squareDistance)
Parameters
Returns
InRangeOf(EntityPos, int)
Returns true if the entity is within given distance of the other entity
public bool InRangeOf(EntityPos position, int squareDistance)
Parameters
Returns
InRangeOf(BlockPos, float)
Returns true if the entity is within given distance of given block position
public bool InRangeOf(BlockPos pos, float squareDistance)
Parameters
Returns
InRangeOf(Vec3d, float, float)
Returns true if the entity is within given distance of given position
public bool InRangeOf(Vec3d position, float horRangeSq, float vertRange)
Parameters
Returns
InRangeOf(Vec3f, float)
Returns true if the entity is within given distance of given position
public bool InRangeOf(Vec3f pos, float squareDistance)
Parameters
Returns
OnlyAnglesToString()
public string OnlyAnglesToString()
Returns
OnlyPosToString()
public string OnlyPosToString()
Returns
SetAngles(float, float, float)
Sets the entity position.
public EntityPos SetAngles(float roll, float yaw, float pitch)
Parameters
Returns
SetAngles(EntityPos)
Sets the entity angles.
public EntityPos SetAngles(EntityPos pos)
Parameters
pos
EntityPos
Returns
SetFrom(EntityPos)
Loads the position and angles from given entity position.
public EntityPos SetFrom(EntityPos pos)
Parameters
pos
EntityPos
Returns
- EntityPos
Returns itself
SetFrom(Vec3d)
Loads the position from given position.
public EntityPos SetFrom(Vec3d pos)
Parameters
pos
Vec3d
Returns
- EntityPos
Returns itself
SetPos(double, double, double)
Sets the entity position.
public EntityPos SetPos(double x, double y, double z)
Parameters
Returns
SetPos(int, int, int)
Sets the entity position.
public EntityPos SetPos(int x, int y, int z)
Parameters
Returns
SetPos(EntityPos)
Sets the entity position.
public EntityPos SetPos(EntityPos pos)
Parameters
pos
EntityPos
Returns
SetPos(BlockPos)
Sets the entity position.
public EntityPos SetPos(BlockPos pos)
Parameters
pos
BlockPos
Returns
SetPos(Vec3d)
Sets this position to a Vec3d, without dimension information - needed in some situations where no dimension change is intended
public void SetPos(Vec3d pos)
Parameters
pos
Vec3dThe Vec3d to set to.
SetPosWithDimension(Vec3d)
Sets this position to a Vec3d, including setting the dimension
public void SetPosWithDimension(Vec3d pos)
Parameters
pos
Vec3dThe Vec3d to set to.
SetYaw(float)
Sets the Yaw of this entity.
public EntityPos SetYaw(float yaw)
Parameters
yaw
float
Returns
SquareDistanceTo(double, double, double)
Returns the squared distance of the entity to this position. Note: dimension aware, this requires the parameter y coordinate also to be based on InternalY as it should be (like EntityPos.XYZ)
public float SquareDistanceTo(double x, double y, double z)
Parameters
Returns
SquareDistanceTo(float, float, float)
Returns the squared distance of the entity to this position
public float SquareDistanceTo(float x, float y, float z)
Parameters
Returns
SquareDistanceTo(EntityPos)
Returns the squared distance of the entity to this position
public float SquareDistanceTo(EntityPos pos)
Parameters
pos
EntityPos
Returns
SquareDistanceTo(Vec3d)
Returns the squared distance of the entity to this position. Note: dimension aware, this requires the parameter Vec3d pos.Y coordinate also to be based on InternalY as it should be (like EntityPos.XYZ)
public double SquareDistanceTo(Vec3d pos)
Parameters
pos
Vec3d
Returns
SquareHorDistanceTo(Vec3d)
Returns the horizontal squared distance of the entity to this position
public double SquareHorDistanceTo(Vec3d pos)
Parameters
pos
Vec3d
Returns
ToBytes(BinaryWriter)
Serializes all positional information. Does not write HeadYaw and HeadPitch.
public void ToBytes(BinaryWriter writer)
Parameters
writer
BinaryWriter
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.