Table of Contents

Struct FastVec3i

Namespace
Vintagestory.API.MathTools
Assembly
VintagestoryAPI.dll

Represents a vector of 3 ints, similar to a Vec3i or a BlockPos but this is a struct

[ProtoContract]
public struct FastVec3i : IEquatable<FastVec3i>, IEquatable<BlockPos>
Implements
Inherited Members
Extension Methods

Constructors

FastVec3i(int, int, int)

Create a new vector with given coordinates

public FastVec3i(int x, int y, int z)

Parameters

x int
y int
z int

FastVec3i(int[])

Create a new vector with given coordinates

public FastVec3i(int[] values)

Parameters

values int[]

FastVec3i(BlockPos)

Create a new vector with given coordinates

public FastVec3i(BlockPos pos)

Parameters

pos BlockPos

FastVec3i(Vec3i)

public FastVec3i(Vec3i vec3i)

Parameters

vec3i Vec3i

Fields

X

The X-Component of the vector

[ProtoMember(1)]
public int X

Field Value

int

Y

The Y-Component of the vector

[ProtoMember(2)]
public int Y

Field Value

int

Z

The Z-Component of the vector

[ProtoMember(3)]
public int Z

Field Value

int

Properties

B

Synonum for Z

public int B { get; set; }

Property Value

int

G

Synonum for Y

public int G { get; set; }

Property Value

int

this[int]

Returns the n-th coordinate

public int this[int index] { get; set; }

Parameters

index int

Property Value

int

R

Synonum for X

public int R { get; set; }

Property Value

int

Methods

Add(int, int, int)

Adds given x/y/z coordinates to the vector

public FastVec3i Add(int x, int y, int z)

Parameters

x int
y int
z int

Returns

FastVec3i

Add(BlockFacing, int)

Offsets the position into the direction of given block face

public FastVec3i Add(BlockFacing facing, int length = 1)

Parameters

facing BlockFacing
length int

Returns

FastVec3i

Add(FastVec3i)

Offsets the position by given xyz vector

public FastVec3i Add(FastVec3i vector)

Parameters

vector FastVec3i

Returns

FastVec3i

Add(Vec3i)

Offsets the position by given xyz vector

public FastVec3i Add(Vec3i vector)

Parameters

vector Vec3i

Returns

FastVec3i

AddCopy(BlockFacing, int)

Creates a copy of this blocks position and offsets it in the direction of given block face

public FastVec3i AddCopy(BlockFacing facing, int length = 1)

Parameters

facing BlockFacing
length int

Returns

FastVec3i

AddCopy(FastVec3i)

Adds both vectors into a new vector. Both source vectors remain unchanged.

public FastVec3i AddCopy(FastVec3i vec)

Parameters

vec FastVec3i

Returns

FastVec3i

Clone()

Creates a copy of the vetor

public FastVec3i Clone()

Returns

FastVec3i

CreateFromBytes(BinaryReader)

public static FastVec3i CreateFromBytes(BinaryReader reader)

Parameters

reader BinaryReader

Returns

FastVec3i

Distance(FastVec3i)

Calculates the distance the two endpoints

public float Distance(FastVec3i vec)

Parameters

vec FastVec3i

Returns

float

Distance(Vec3d)

Calculates the distance the two endpoints

public float Distance(Vec3d vec)

Parameters

vec Vec3d

Returns

float

DistanceSq(double, double, double)

Calculates the square distance the two endpoints

public double DistanceSq(double x, double y, double z)

Parameters

x double
y double
z double

Returns

double

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(BlockPos)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(BlockPos other)

Parameters

other BlockPos

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(FastVec3i)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(FastVec3i other)

Parameters

other FastVec3i

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(Vec3i)

public bool Equals(Vec3i other)

Parameters

other Vec3i

Returns

bool

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Length()

Returns the length of this vector

public float Length()

Returns

float

Mul(int)

Multiplies each coordinate with given multiplier

public FastVec3i Mul(int multiplier)

Parameters

multiplier int

Returns

FastVec3i

Negate()

public void Negate()

Set(int, int, int)

Sets the vector to this coordinates

public FastVec3i Set(int x, int y, int z)

Parameters

x int
y int
z int

Returns

FastVec3i

Set(int[])

public FastVec3i Set(int[] vec)

Parameters

vec int[]

Returns

FastVec3i

Set(BlockPos)

public FastVec3i Set(BlockPos pos)

Parameters

pos BlockPos

Returns

FastVec3i

Set(FastVec3i)

Sets the vector to the coordinates of given vector

public void Set(FastVec3i vec)

Parameters

vec FastVec3i

Set(Vec3d)

Sets the vector to the coordinates of given vector

public FastVec3i Set(Vec3d vec)

Parameters

vec Vec3d

Returns

FastVec3i

Sub(FastVec3i)

Subtract a position => you'll have the manhattan distance

public FastVec3i Sub(FastVec3i pos)

Parameters

pos FastVec3i

Returns

FastVec3i

ToString()

Simple string represenation of the x/y/z components

public override string ToString()

Returns

string

ToVec3d()

Creates a new double precision vector with the same coordinates

public Vec3d ToVec3d()

Returns

Vec3d

Write(BinaryWriter)

public void Write(BinaryWriter writer)

Parameters

writer BinaryWriter

Operators

operator +(FastVec3i, BlockPos)

public static FastVec3i operator +(FastVec3i left, BlockPos right)

Parameters

left FastVec3i
right BlockPos

Returns

FastVec3i

operator +(FastVec3i, FastVec3i)

public static FastVec3i operator +(FastVec3i left, FastVec3i right)

Parameters

left FastVec3i
right FastVec3i

Returns

FastVec3i

operator ==(FastVec3i, FastVec3i)

public static bool operator ==(FastVec3i left, FastVec3i right)

Parameters

left FastVec3i
right FastVec3i

Returns

bool

operator !=(FastVec3i, FastVec3i)

public static bool operator !=(FastVec3i left, FastVec3i right)

Parameters

left FastVec3i
right FastVec3i

Returns

bool