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.
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.
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: AssemblyIdThe assembly (stage-5 assemblies ref) whose hitbox is the target.
Implementations§
Source§impl TriggerOn
impl TriggerOn
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
The kebab tag (strike / use / approach / step / strike-npc /
strike-assembly).
Sourcepub fn is_click(&self) -> bool
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.
Sourcepub fn needs_anchor(&self) -> bool
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.
Sourcepub fn assembly_target(&self) -> Option<&AssemblyId>
pub fn assembly_target(&self) -> Option<&AssemblyId>
The assembly whose hitbox this event watches (strike-assembly only).
Sourcepub fn npc_target(&self) -> Option<&NpcId>
pub fn npc_target(&self) -> Option<&NpcId>
The NPC whose body this event watches (strike-npc only).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TriggerOn
impl<'de> Deserialize<'de> for TriggerOn
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for TriggerOn
impl JsonSchema for TriggerOn
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more