Table of Contents

Class Vec3i

Namespace
Vintagestory.API.MathTools
Assembly
VintagestoryAPI.dll

Represents a vector of 3 ints. Go bug Tyron if you need more utility methods in this class.

[ProtoContract]
[JsonObject(MemberSerialization.OptIn)]
public class Vec3i : IEquatable<Vec3i>, IVec3
Inheritance
Vec3i
Implements
Inherited Members
Extension Methods

Constructors

Vec3i()

public Vec3i()

Vec3i(int, int, int)

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

Parameters

x int
y int
z int

Vec3i(BlockPos)

public Vec3i(BlockPos pos)

Parameters

pos BlockPos

Fields

DirectAndIndirectNeighbours

List of offset of all direct and indirect neighbours of coordinate 0/0/0

public static readonly Vec3i[] DirectAndIndirectNeighbours

Field Value

Vec3i[]

X

[ProtoMember(1)]
[JsonProperty]
public int X

Field Value

int

Y

[ProtoMember(2)]
[JsonProperty]
public int Y

Field Value

int

Z

[ProtoMember(3)]
[JsonProperty]
public int Z

Field Value

int

Properties

AsBlockPos

public BlockPos AsBlockPos { get; }

Property Value

BlockPos

AsVec3i

public Vec3i AsVec3i { get; }

Property Value

Vec3i

IsZero

public bool IsZero { get; }

Property Value

bool

this[int]

Returns the n-th coordinate

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

Parameters

index int

Property Value

int

XZ

public Vec2i XZ { get; }

Property Value

Vec2i

Zero

public static Vec3i Zero { get; }

Property Value

Vec3i

Methods

Add(int, int, int)

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

Parameters

x int
y int
z int

Returns

Vec3i

Add(int, int, int, Vec3i)

public Vec3i Add(int x, int y, int z, Vec3i intoVec)

Parameters

x int
y int
z int
intoVec Vec3i

Returns

Vec3i

Add(BlockFacing, int)

public Vec3i Add(BlockFacing towardsFace, int length = 1)

Parameters

towardsFace BlockFacing
length int

Returns

Vec3i

AddCopy(int, int, int)

public Vec3i AddCopy(int x, int y, int z)

Parameters

x int
y int
z int

Returns

Vec3i

AddCopy(BlockFacing)

public Vec3i AddCopy(BlockFacing facing)

Parameters

facing BlockFacing

Returns

Vec3i

Clone()

public Vec3i Clone()

Returns

Vec3i

DistanceTo(Vec3i)

public double DistanceTo(Vec3i vec)

Parameters

vec Vec3i

Returns

double

Equals(int, int, int)

public bool Equals(int x, int y, int z)

Parameters

x int
y int
z int

Returns

bool

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

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

Equals(Vec3i)

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

public bool Equals(Vec3i other)

Parameters

other Vec3i

An object to compare with this object.

Returns

bool

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

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

ManhattenDistanceTo(Vec3i)

public int ManhattenDistanceTo(Vec3i vec)

Parameters

vec Vec3i

Returns

int

Reduce(int)

Substracts val from each coordinate if the coordinate if positive, otherwise it is added. If 0, the value is unchanged. The value must be a positive number

public void Reduce(int val = 1)

Parameters

val int

ReduceX(int)

public void ReduceX(int val = 1)

Parameters

val int

ReduceY(int)

public void ReduceY(int val = 1)

Parameters

val int

ReduceZ(int)

public void ReduceZ(int val = 1)

Parameters

val int

Set(int, int, int)

public Vec3i Set(int positionX, int positionY, int positionZ)

Parameters

positionX int
positionY int
positionZ int

Returns

Vec3i

Set(Vec3i)

public Vec3i Set(Vec3i fromPos)

Parameters

fromPos Vec3i

Returns

Vec3i

SquareDistanceTo(int, int, int)

public long SquareDistanceTo(int x, int y, int z)

Parameters

x int
y int
z int

Returns

long

SquareDistanceTo(Vec3i)

public long SquareDistanceTo(Vec3i vec)

Parameters

vec Vec3i

Returns

long

ToBlockPos()

public BlockPos ToBlockPos()

Returns

BlockPos

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Operators

operator +(Vec3i, Vec3i)

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

Parameters

left Vec3i
right Vec3i

Returns

Vec3i

operator /(Vec3i, int)

public static Vec3i operator /(Vec3i left, int right)

Parameters

left Vec3i
right int

Returns

Vec3i

operator ==(Vec3i, Vec3i)

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

Parameters

left Vec3i
right Vec3i

Returns

bool

operator !=(Vec3i, Vec3i)

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

Parameters

left Vec3i
right Vec3i

Returns

bool

operator *(int, Vec3i)

public static Vec3i operator *(int left, Vec3i right)

Parameters

left int
right Vec3i

Returns

Vec3i

operator *(Vec3i, int)

public static Vec3i operator *(Vec3i left, int right)

Parameters

left Vec3i
right int

Returns

Vec3i

operator -(Vec3i, Vec3i)

public static Vec3i operator -(Vec3i left, Vec3i right)

Parameters

left Vec3i
right Vec3i

Returns

Vec3i

operator -(Vec3i)

public static Vec3i operator -(Vec3i vec)

Parameters

vec Vec3i

Returns

Vec3i