Table of Contents

Class Collider

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll

A registration snapshot containing one or more world-space collision boxes. Open in GitHub

public sealed class Collider
Inheritance
Collider
Inherited Members
Extension Methods

Properties

Bounds

The conservative axis-aligned bounds of this collider. The returned cuboid is owned by this snapshot and must not be modified.

public Cuboidd Bounds { get; }

Property Value

Cuboidd

CanCarryEntities

Whether controlled entities standing on this collider should follow its transform.

public bool CanCarryEntities { get; }

Property Value

bool

CollisionBoxCount

public int CollisionBoxCount { get; }

Property Value

int

CollisionLayer

public CollisionLayer CollisionLayer { get; }

Property Value

CollisionLayer

CollisionMask

public CollisionLayer CollisionMask { get; }

Property Value

CollisionLayer

Dimension

public int Dimension { get; }

Property Value

int

Id

The scene-local registration ID, retained across updates and never reused. Do not persist this ID or send it across the network.

public long Id { get; }

Property Value

long

IsTransformed

True when this collider was registered with local geometry and a transform.

public bool IsTransformed { get; }

Property Value

bool

KeepsSupportedEntitiesDry

Whether controlled entities supported by this collider should ignore liquid occupying the same world position.

public bool KeepsSupportedEntitiesDry { get; }

Property Value

bool

OwnerColliderCode

The stable owner-local code used to resolve this collider independently on each side.

public string? OwnerColliderCode { get; }

Property Value

string

OwnerEntityId

The entity whose own physics should ignore this collider, or zero when the collider has no entity owner.

public long OwnerEntityId { get; }

Property Value

long

PreviousTransform

The preceding rigid transform used to derive point velocity.

public ColliderTransform PreviousTransform { get; }

Property Value

ColliderTransform

SelectionPosition

The block represented when this collider is selected, or null when the collider is not selectable.

public BlockPos? SelectionPosition { get; }

Property Value

BlockPos

Transform

The current rigid transform. This is the identity transform for a world-space collider.

public ColliderTransform Transform { get; }

Property Value

ColliderTransform

TransformElapsedSeconds

The elapsed seconds between PreviousTransform and Transform, or zero when velocity is not known.

public double TransformElapsedSeconds { get; }

Property Value

double

Methods

CollectSweepHits(TransformedCuboidd, double, double, double, List<CollisionHit>, bool)

Appends one shared hit per intersected collision box to a caller-owned list without clearing or sorting it.

public void CollectSweepHits(TransformedCuboidd movingBox, double motionX, double motionY, double motionZ, List<CollisionHit> results, bool includeInitialOverlap = true)

Parameters

movingBox TransformedCuboidd
motionX double
motionY double
motionZ double
results List<CollisionHit>
includeInitialOverlap bool

GetCollisionBox(int)

Gets an exact collision box owned by this snapshot. The returned cuboid must not be modified.

public Cuboidd GetCollisionBox(int index)

Parameters

index int

Returns

Cuboidd

GetCollisionBoxBounds(int)

Gets the conservative axis-aligned bounds of a collision box. The returned cuboid must not be modified.

public Cuboidd GetCollisionBoxBounds(int index)

Parameters

index int

Returns

Cuboidd

GetPointVelocity(double, double, double, out double, out double, out double)

Gets the world velocity of a collider-local point in blocks per second.

public void GetPointVelocity(double localX, double localY, double localZ, out double velocityX, out double velocityY, out double velocityZ)

Parameters

localX double
localY double
localZ double
velocityX double
velocityY double
velocityZ double

GetPointVelocity(FastVec3d, out FastVec3d)

public void GetPointVelocity(FastVec3d localPoint, out FastVec3d velocity)

Parameters

localPoint FastVec3d
velocity FastVec3d

GetSelectionBoxIndex(int)

Gets the owning block's selection-box index for a collision box.

public int GetSelectionBoxIndex(int collisionBoxIndex)

Parameters

collisionBoxIndex int

Returns

int

Intersects(Cuboidd)

Tests whether any box in this collider intersects the supplied axis-aligned box.

public bool Intersects(Cuboidd box)

Parameters

box Cuboidd

Returns

bool

Intersects(TransformedCuboidd)

Tests whether any box in this collider intersects the supplied transformed cuboid.

public bool Intersects(TransformedCuboidd box)

Parameters

box TransformedCuboidd

Returns

bool

IntersectsOrTouches(Cuboidd)

Tests whether any box in this collider intersects or touches the supplied axis-aligned box.

public bool IntersectsOrTouches(Cuboidd box)

Parameters

box Cuboidd

Returns

bool

IntersectsOrTouches(TransformedCuboidd)

Tests whether any box in this collider intersects or touches the supplied transformed cuboid.

public bool IntersectsOrTouches(TransformedCuboidd box)

Parameters

box TransformedCuboidd

Returns

bool

PushOutX(Cuboidd, double, ref EnumPushDirection)

public double PushOutX(Cuboidd box, double motion, ref EnumPushDirection direction)

Parameters

box Cuboidd
motion double
direction EnumPushDirection

Returns

double

PushOutY(Cuboidd, double, ref EnumPushDirection)

public double PushOutY(Cuboidd box, double motion, ref EnumPushDirection direction)

Parameters

box Cuboidd
motion double
direction EnumPushDirection

Returns

double

PushOutZ(Cuboidd, double, ref EnumPushDirection)

public double PushOutZ(Cuboidd box, double motion, ref EnumPushDirection direction)

Parameters

box Cuboidd
motion double
direction EnumPushDirection

Returns

double

TryGetAABBContact(int, Cuboidd, double, out CuboidContact)

Gets the outward contact normal and signed separation from one collision box to a nearby axis-aligned box.

public bool TryGetAABBContact(int collisionBoxIndex, Cuboidd box, double maxSeparation, out CuboidContact contact)

Parameters

collisionBoxIndex int
box Cuboidd
maxSeparation double
contact CuboidContact

Returns

bool

TryGetAABBPenetration(int, Cuboidd, out double, out double, out double)

Gets the shortest translation which moves an overlapping axis-aligned cuboid out of one collision box.

public bool TryGetAABBPenetration(int collisionBoxIndex, Cuboidd box, out double translationX, out double translationY, out double translationZ)

Parameters

collisionBoxIndex int
box Cuboidd
translationX double
translationY double
translationZ double

Returns

bool

TrySweep(TransformedCuboidd, double, double, double, out double)

Finds the first contact while a transformed cuboid translates through this collider without rotating. On success, collisionFraction is in the range from zero inclusive to one exclusive; otherwise it is one.

public bool TrySweep(TransformedCuboidd movingBox, double motionX, double motionY, double motionZ, out double collisionFraction)

Parameters

movingBox TransformedCuboidd
motionX double
motionY double
motionZ double
collisionFraction double

Returns

bool

TrySweepAABB(Cuboidd, double, double, double, out double)

Finds the first contact while an axis-aligned box translates through this collider. On success, collisionFraction is in the range from zero inclusive to one exclusive; otherwise it is one.

public bool TrySweepAABB(Cuboidd movingBox, double motionX, double motionY, double motionZ, out double collisionFraction)

Parameters

movingBox Cuboidd
motionX double
motionY double
motionZ double
collisionFraction double

Returns

bool

WithTransform(int, ColliderTransform, double)

Creates an unpublished snapshot at another pose, sharing this collider's local geometry.

public Collider WithTransform(int dimension, ColliderTransform transform, double elapsedSeconds = 0)

Parameters

dimension int
transform ColliderTransform
elapsedSeconds double

Returns

Collider