Skip to main content

TriggerOn

Enum TriggerOn 

Source
pub enum TriggerOn {
    Strike,
    Use,
    Approach {
        range: u32,
    },
    Step,
    StrikeNpc {
        npc: NpcId,
    },
    StrikeAssembly {
        assembly: AssemblyId,
    },
}
Expand description

The event an EnvTrigger watches (DSL v0.4).

Variants§

§

Strike

The player attacks (left-clicks) the interaction entity at the anchor.

§

Use

The player uses (right-clicks) the interaction entity at the anchor.

§

Approach

The player comes within range blocks of the anchor.

Fields

§range: u32

Approach radius (blocks).

§

Step

A player steps onto the anchor’s cell, which holds a block a step fires — a pressure plate or the tripwire string (stepped_blocks); the piece places it, and a cell that holds anything else is DW0917.

Detected as a player whose hitbox is in the cell (the selector a plate or tripwire trap fires on), edge-latched so standing on the plate fires once. With audience: presser each player who steps on is dispatched as @s on their own step: the act and the actor are the same fact, a body in the cell, so no player is inferred after the event.

§

StrikeNpc

The player attacks (left-clicks) an NPC’s body (DSL v0.6).

The place-based TriggerOn::Strike cannot express “hit the giant”: it summons its own minecraft:interaction at a cell, and a large NPC’s body eclipses that cell (DW0359), so the click never reaches the trigger — the owner’s island round-7 finding. This form has no cell. It rides the interaction entity the NPC already owns, which is the entity a click on that NPC reaches by construction.

Right-click and left-click stay separate all the way down: a minecraft:interaction records them in two distinct NBT fields (interaction and attack), so the NPC’s dialogue keeps the right-click and this trigger takes the left-click, on one shared hitbox.

Fields

§npc: NpcId

The NPC (stage-2 ref) whose body is the target.

§

StrikeAssembly

The player attacks (left-clicks) an assembly’s hitbox (spec-0082).

The exact shape of TriggerOn::StrikeNpc: no at, because the target is an object with a hitbox of its own, and the trigger rides it. Melee only — the hitbox is a minecraft:interaction, and an arrow passes through one without writing its attack record (spec-0082 §8 row 5). once: false with an add-state is how a hit count is built.

Fields

§assembly: AssemblyId

The assembly (stage-5 assemblies ref) whose hitbox is the target.

Implementations§

Source§

impl TriggerOn

Source

pub fn kind(&self) -> &'static str

The kebab tag (strike / use / approach / step / strike-npc / strike-assembly).

Source

pub fn is_click(&self) -> bool

Whether this event is a click on a minecraft:interaction hitbox — a strike, a use, a strike-npc, a strike-assembly. An approach and a step are a body’s position, read on the tick, and have no hitbox.

Source

pub fn needs_anchor(&self) -> bool

Whether this event needs an at anchor — true for everything that watches a place, false for strike-npc and strike-assembly, which watch an object that carries its own hitbox.

Source

pub fn assembly_target(&self) -> Option<&AssemblyId>

The assembly whose hitbox this event watches (strike-assembly only).

Source

pub fn npc_target(&self) -> Option<&NpcId>

The NPC whose body this event watches (strike-npc only).

Trait Implementations§

Source§

impl Clone for TriggerOn

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 Debug for TriggerOn

Source§

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

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

impl<'de> Deserialize<'de> for TriggerOn

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for TriggerOn

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for TriggerOn

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 Serialize for TriggerOn

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TriggerOn

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.