Skip to main content

Collision

Enum Collision 

Source
pub enum Collision {
    Air,
    Thin(u8),
    PartialFloor(u8),
    FullCube,
    TallBarrier,
    FenceGate,
    Fluid,
    Climbable,
}
Expand description

What a block state does to a body. The classification every walk in this workspace reads; see the module header for the table it stands for.

Deliberately an enum rather than a pair of booleans: the six classes are not the four corners of two independent questions, and naming them is what lets a caller that needs more than passability — a gate is openable, a fluid drowns — ask for the distinction instead of re-deriving it from a block name.

Variants§

§

Air

One of the three air blocks: nothing here at all.

§

Thin(u8)

An empty or sub-auto-step collision box — a torch, a carpet, a candle, a pressure plate, a tuft of grass. Carries the measured top face, which is under THIN_HEIGHT_16 by construction and is not a floor level.

§

PartialFloor(u8)

A floor whose walkable top face is below the cell top: a bottom slab, a deep snow drift, a dirt_path. Carries that height in sixteenths.

§

FullCube

A full 1×1×1 cube — the conservative default for everything unrecognised.

§

TallBarrier

A fence or a wall: 1.5 blocks tall on a 1-block cell, so a body neither passes through it nor reaches its top.

§

FenceGate

A fence gate: a body opens it with the adventure-legal right-click and walks through. Never a floor.

§

Fluid

Water or lava filling the cell: a body swims, and stands on nothing.

§

Climbable

A block a body climbs (climbable, every member of #minecraft:climbable but scaffolding): a ladder’s 3/16 panel against its support, or a vine’s empty box. A body centred in the cell is clear of it, and stands on nothing there — what holds a body in this cell is the climb, and the climb is the nav model’s to judge, with the hold its support gives it (spec-0099).

Implementations§

Source§

impl Collision

Source

pub fn passes_body(self) -> bool

Can a body’s own volume occupy this cell?

Source

pub fn supports_body(self) -> bool

Can a body stand on this cell? Not the complement of Collision::passes_body, and that is the whole reason it is a separate question — a torch is neither, and lava is neither from the other side.

Source

pub fn floor_top_16(self) -> Option<u8>

The walkable top face of this block, in sixteenths above its own cell floor, for a class that supports a body. None for every class that does not, so a caller cannot silently read a height off a torch.

Trait Implementations§

Source§

impl Clone for Collision

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Collision

Source§

impl Debug for Collision

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Collision

Source§

impl PartialEq for Collision

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Collision

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.