Table of Contents

Class EntityPos

Namespace
Vintagestory.API.Common.Entities
Assembly
VintagestoryAPI.dll

Represents all positional information of an entity, such as coordinates, motion and angles

public class EntityPos
Inheritance
EntityPos
Derived
Inherited Members

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

x double
y double
z double
heading float
pitch float
roll float

Fields

Dimension

public int Dimension

Field Value

int

HeadPitch

The pitch of the agents head

public float HeadPitch

Field Value

float

HeadYaw

The yaw of the agents head

public float HeadYaw

Field Value

float

Motion

public Vec3d Motion

Field Value

Vec3d

dimension

protected int dimension

Field Value

int

pitch

protected float pitch

Field Value

float

roll

protected float roll

Field Value

float

stance

protected int stance

Field Value

int

x

protected double x

Field Value

double

y

protected double y

Field Value

double

yaw

protected float yaw

Field Value

float

z

protected double z

Field Value

double

Properties

AsBlockPos

Returns the position as BlockPos object

public BlockPos AsBlockPos { get; }

Property Value

BlockPos

InternalY

public virtual double InternalY { get; }

Property Value

double

Pitch

The rotation around the Z axis, in radians.

public virtual float Pitch { get; set; }

Property Value

float

Roll

The rotation around the X axis, in radians.

public virtual float Roll { get; set; }

Property Value

float

X

The X position of the Entity.

public virtual double X { get; set; }

Property Value

double

XYZ

Returns the position as a Vec3d object

public Vec3d XYZ { get; }

Property Value

Vec3d

XYZFloat

Returns the position as a Vec3f object

public Vec3f XYZFloat { get; }

Property Value

Vec3f

XYZInt

Returns the position as a Vec3i object

public Vec3i XYZInt { get; }

Property Value

Vec3i

Y

The Y position of the Entity.

public virtual double Y { get; set; }

Property Value

double

Yaw

The rotation around the Y axis, in radians.

public virtual float Yaw { get; set; }

Property Value

float

Z

The Z position of the Entity.

public virtual double Z { get; set; }

Property Value

double

Methods

Add(double, double, double)

public EntityPos Add(double x, double y, double z)

Parameters

x double
y double
z double

Returns

EntityPos

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

EntityPos

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

pos EntityPos
epsilon double

Returns

bool

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

pos EntityPos
epsilon double

Returns

bool

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

pos EntityPos
epsilon double

Returns

bool

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

EntityPos

Copy()

Creates a full copy

public EntityPos Copy()

Returns

EntityPos

DistanceTo(EntityPos)

public double DistanceTo(EntityPos pos)

Parameters

pos EntityPos

Returns

double

DistanceTo(Vec3d)

public double DistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

double

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

Vec3f

GetViewVector(float, float)

Same as AheadCopy(1) - AheadCopy(0)

public static Vec3f GetViewVector(float pitch, float yaw)

Parameters

pitch float
yaw float

Returns

Vec3f

HorDistanceTo(EntityPos)

public double HorDistanceTo(EntityPos pos)

Parameters

pos EntityPos

Returns

double

HorDistanceTo(Vec3d)

public double HorDistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

double

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

EntityPos

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

x int
z int
squareDistance float

Returns

bool

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

x double
y double
z double
squareDistance float

Returns

bool

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

x int
y int
z int
squareDistance float

Returns

bool

InRangeOf(EntityPos, int)

Returns true if the entity is within given distance of the other entity

public bool InRangeOf(EntityPos position, int squareDistance)

Parameters

position EntityPos
squareDistance int

Returns

bool

InRangeOf(BlockPos, float)

Returns true if the entity is within given distance of given block position

public bool InRangeOf(BlockPos pos, float squareDistance)

Parameters

pos BlockPos
squareDistance float

Returns

bool

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

position Vec3d
horRangeSq float
vertRange float

Returns

bool

InRangeOf(Vec3f, float)

Returns true if the entity is within given distance of given position

public bool InRangeOf(Vec3f pos, float squareDistance)

Parameters

pos Vec3f
squareDistance float

Returns

bool

OnlyAnglesToString()

public string OnlyAnglesToString()

Returns

string

OnlyPosToString()

public string OnlyPosToString()

Returns

string

SetAngles(float, float, float)

Sets the entity position.

public EntityPos SetAngles(float roll, float yaw, float pitch)

Parameters

roll float
yaw float
pitch float

Returns

EntityPos

SetAngles(EntityPos)

Sets the entity angles.

public EntityPos SetAngles(EntityPos pos)

Parameters

pos EntityPos

Returns

EntityPos

SetFrom(EntityPos)

Loads the position and angles from given entity position.

public void SetFrom(EntityPos pos)

Parameters

pos EntityPos

SetFrom(Vec3d)

Loads the position from given position.

public void SetFrom(Vec3d pos)

Parameters

pos Vec3d

SetPos(double, double, double)

Sets the entity position.

public EntityPos SetPos(double x, double y, double z)

Parameters

x double
y double
z double

Returns

EntityPos

SetPos(int, int, int)

Sets the entity position.

public EntityPos SetPos(int x, int y, int z)

Parameters

x int
y int
z int

Returns

EntityPos

SetPos(EntityPos)

Sets the entity position.

public EntityPos SetPos(EntityPos pos)

Parameters

pos EntityPos

Returns

EntityPos

SetPos(BlockPos)

Sets the entity position.

public EntityPos SetPos(BlockPos pos)

Parameters

pos BlockPos

Returns

EntityPos

SetPos(Vec3d)

Sets this position to a Vec3d

public void SetPos(Vec3d pos)

Parameters

pos Vec3d

The Vec3d to set to.

SetYaw(float)

Sets the Yaw of this entity.

public EntityPos SetYaw(float yaw)

Parameters

yaw float

Returns

EntityPos

SquareDistanceTo(double, double, double)

Returns the squared distance of the entity to this position

public float SquareDistanceTo(double x, double y, double z)

Parameters

x double
y double
z double

Returns

float

SquareDistanceTo(float, float, float)

Returns the squared distance of the entity to this position

public float SquareDistanceTo(float x, float y, float z)

Parameters

x float
y float
z float

Returns

float

SquareDistanceTo(EntityPos)

Returns the squared distance of the entity to this position

public float SquareDistanceTo(EntityPos pos)

Parameters

pos EntityPos

Returns

float

SquareDistanceTo(Vec3d)

Returns the squared distance of the entity to this position

public double SquareDistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

double

SquareHorDistanceTo(Vec3d)

Returns the horizontal squared distance of the entity to this position

public double SquareHorDistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

double

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.