Skip to main content

Leashable

Trait Leashable 

Source
pub trait Leashable: Entity {
Show 26 methods // Required method fn leash_data(&self) -> &SyncMutex<Option<LeashData>>; // Provided methods fn is_leashed(&self) -> bool { ... } fn may_be_leashed(&self) -> bool { ... } fn leash_holder(&self) -> Option<SharedEntity> { ... } fn leash_attachment(&self) -> Option<LeashAttachment> { ... } fn set_delayed_leash_attachment(&self, attachment: LeashAttachment) { ... } fn can_be_leashed(&self) -> bool { ... } fn leash_distance_to(&self, holder: &dyn Entity) -> f64 { ... } fn leash_snap_distance(&self) -> f64 { ... } fn leash_elastic_distance(&self) -> f64 { ... } fn when_leashed_to(&self, holder: &dyn Entity) { ... } fn leash_too_far_behaviour(&self) { ... } fn on_elastic_leash_pull(&self) { ... } fn close_range_leash_behaviour(&self, _holder: &dyn Entity) { ... } fn check_elastic_interactions(&self, holder: &dyn Entity) -> bool { ... } fn apply_leash_angular_momentum(&self) -> bool { ... } fn rotate_by_leash_angular_momentum(&self, angular_momentum: f64) { ... } fn leash_angular_momentum(&self) -> Option<f64> { ... } fn leash_angular_friction(&self) -> f64 { ... } fn can_have_a_leash_attached_to(&self, holder: &dyn Entity) -> bool { ... } fn set_leashed_to(&self, holder: &SharedEntity) -> bool { ... } fn restore_leash_from_save(&self) { ... } fn tick_leash(&self) { ... } fn drop_leash(&self) { ... } fn remove_leash(&self) { ... } fn remove_leash_state(&self) -> Option<SharedEntity> { ... }
}
Expand description

Vanilla behavior shared by entities that extend Leashable.

Leashable entities can be leashed to an entity holding a lead, or a fence holding a lead.

Required Methods§

Source

fn leash_data(&self) -> &SyncMutex<Option<LeashData>>

Returns the shared leash data (if any).

Provided Methods§

Source

fn is_leashed(&self) -> bool

Returns whether this entity is leashed.

Source

fn may_be_leashed(&self) -> bool

Returns whether this entity can be leashed with respect to its leash state.

In other words, this returns false if the entity is already leashed and true if not.

See also: Leashable::can_be_leashed

Source

fn leash_holder(&self) -> Option<SharedEntity>

Returns the entity holding this entity with a leash, if any.

Source

fn leash_attachment(&self) -> Option<LeashAttachment>

Source

fn set_delayed_leash_attachment(&self, attachment: LeashAttachment)

Source

fn can_be_leashed(&self) -> bool

Returns whether this entity can be leashed with respect to the entity’s type or classification.

For example, mobs like dolphins and hoglins return true for this, while villagers return false.

See also: Leashable::may_be_leashed

Source

fn leash_distance_to(&self, holder: &dyn Entity) -> f64

Returns the distance between the bounding box’s center of the entity and that of holder.

Despite the same, this function does not check for any leash state.

Source

fn leash_snap_distance(&self) -> f64

Returns the minimum leash distance for which a leash will snap.

Source

fn leash_elastic_distance(&self) -> f64

Returns the minimum leash distance for which a leash behaves elastically (it pulls the leashed entity towards the holder).

Source

fn when_leashed_to(&self, holder: &dyn Entity)

Called when this entity is leashed to holder.

Source

fn leash_too_far_behaviour(&self)

Called every tick this entity’s leash is stretched too far (this entity is too far from its holder).

Source

fn on_elastic_leash_pull(&self)

Called every tick this entity’s leash starts acting elastic (it pulls the leashed entity towards the holder).

Source

fn close_range_leash_behaviour(&self, _holder: &dyn Entity)

Called every tick this leash is not elastic (pulling) or snappable.

Source

fn check_elastic_interactions(&self, holder: &dyn Entity) -> bool

Performs the calculations to pull this entity towards its leash holder and applies velocity to it.

Source

fn apply_leash_angular_momentum(&self) -> bool

Applies some angular momentum by the leash for rotation purposes.

Source

fn rotate_by_leash_angular_momentum(&self, angular_momentum: f64)

Rotates this entity with the provided angular momentum value.

Source

fn leash_angular_momentum(&self) -> Option<f64>

Returns the angular momentum experienced by this entity (if it is leashed).

Source

fn leash_angular_friction(&self) -> f64

Returns the friction multiplier for calculating the angular momentum of a leash.

This is multiplied with the base angular momentum to get the final angular momentum.

Source

fn can_have_a_leash_attached_to(&self, holder: &dyn Entity) -> bool

Returns whether this entity can have a leash attached to another. Mirrors Vanilla’s Leashable.canHaveALeashAttachedTo.

Source

fn set_leashed_to(&self, holder: &SharedEntity) -> bool

Sets this entity to be leashed to a holder, removing the old holder’s connection, if any.

Source

fn restore_leash_from_save(&self)

Updates the delayed leash info to use the entity’s current context to resolve the entity’s actual leash connection (whether it be an external entity or a fence knot).

Source

fn tick_leash(&self)

Ticks the leash holding this entity. Mirrors Vanilla’s Leashable.tickLeash.

Source

fn drop_leash(&self)

Breaks the leash and drops a lead item. Mirrors Vanilla’s Leashable.dropLeash.

Source

fn remove_leash(&self)

Removes the leash without dropping a lead item. Mirrors Vanilla’s Leashable.removeLeash.

Source

fn remove_leash_state(&self) -> Option<SharedEntity>

Removes the leash state of this entity, returning its holder before the leash’s removal, if any.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T: Mob> Leashable for T