Skip to main content

GoalContext

Struct GoalContext 

pub struct GoalContext<'a> { /* private fields */ }
Expand description

What a Goal runs with: its mob, the world read view of the mob’s tick, the mob’s own random, and the writes a goal makes to its own mob.

Reads through host answer the ticking mob itself directly; every other entity answers from the tick’s snapshot — a getEntities of the moment the mob list was taken out — so a read the snapshot does not carry answers None (the mob’s gear, its effects), and writes to other entities are not part of a goal at all. The level’s own reads work as anywhere else.

Implementations§

§

impl<'a> GoalContext<'a>

pub fn mob(&self) -> MobRef

The mob this goal runs on, a fresh handle each call: valid until the world reopens, as every handle is.

pub fn host(&self) -> &dyn Host

The read view of the mob’s tick: the ticking mob directly, other entities from the tick’s snapshot, None where a read is not carried.

pub fn random(&mut self) -> &mut LegacyRandom

The mob’s own random (mob.getRandom()): the stream vanilla’s goals draw from, so a mod’s draws keep the mob’s stream in shape.

pub fn move_to(&mut self, at: [f64; 3], speed: f64) -> bool

getNavigation().moveTo(x, y, z, speed): start a path to at. False when the numbers are not ones the pathfinder takes or no path starts.

pub fn stop_navigation(&mut self)

getNavigation().stop().

pub fn look_at(&mut self, at: [f64; 3])

getLookControl().setLookAt(x, y, z).

pub fn set_target(&mut self, target: Option<LivingRef>) -> bool

setTarget; None clears it. The target resolves through the tick’s view: a mob, or the player the tick sees. False when the target cannot be stored — the mob’s brain owns its target, as the write handle’s own rules refuse — and then the mob’s target is unchanged.

pub fn jump(&mut self)

getJumpControl().jump().

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for GoalContext<'a>

§

impl<'a> !Send for GoalContext<'a>

§

impl<'a> !Sync for GoalContext<'a>

§

impl<'a> !UnwindSafe for GoalContext<'a>

§

impl<'a> Freeze for GoalContext<'a>

§

impl<'a> Unpin for GoalContext<'a>

§

impl<'a> UnsafeUnpin for GoalContext<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.