Trait UnspawnedMobEdits
pub trait UnspawnedMobEdits {
// Required methods
fn set_equipment(
&self,
mob: UnspawnedMobRef,
slot: EquipmentSlot,
item: Option<ItemStack>,
) -> Result<(), UnspawnedMobError>;
fn set_attribute_base(
&self,
mob: UnspawnedMobRef,
attribute: &Identifier,
base: f64,
) -> Result<(), UnspawnedMobError>;
fn add_attribute_modifier(
&self,
mob: UnspawnedMobRef,
attribute: &Identifier,
modifier: AttributeModifier,
) -> Result<(), UnspawnedMobError>;
fn remove_attribute_modifier(
&self,
mob: UnspawnedMobRef,
attribute: &Identifier,
id: &Identifier,
) -> Result<bool, UnspawnedMobError>;
fn add_tag(
&self,
mob: UnspawnedMobRef,
tag: &str,
) -> Result<bool, UnspawnedMobError>;
fn remove_tag(
&self,
mob: UnspawnedMobRef,
tag: &str,
) -> Result<bool, UnspawnedMobError>;
fn set_custom_name(
&self,
mob: UnspawnedMobRef,
name: Option<Text>,
) -> Result<(), UnspawnedMobError>;
}Expand description
The edits a hook may make to the mob it was lent, beside the handle’s reads.
The game hands this out with the UnspawnedMobRef for one hook
call and keeps neither after it returns. Each method takes that handle and reaches only that
mob: another lend’s handle, or one kept from an earlier call, is refused with
UnspawnedMobError::Expired. An edit applies at once, so the handle’s reads, and the next
listener, see it. The editor works where the hook’s host is the read-only one: it changes
nothing in the level, only the mob that is about to join it.
Required Methods§
fn set_equipment(
&self,
mob: UnspawnedMobRef,
slot: EquipmentSlot,
item: Option<ItemStack>,
) -> Result<(), UnspawnedMobError>
fn set_equipment( &self, mob: UnspawnedMobRef, slot: EquipmentSlot, item: Option<ItemStack>, ) -> Result<(), UnspawnedMobError>
Puts item in slot (Mob.setItemSlot): an API-owned stack; None empties the slot. Invalid
item keys, counts, damage or components are refused with Invalid, without changing the
slot. The stack’s attribute modifiers apply to the mob at once.
fn set_attribute_base(
&self,
mob: UnspawnedMobRef,
attribute: &Identifier,
base: f64,
) -> Result<(), UnspawnedMobError>
fn set_attribute_base( &self, mob: UnspawnedMobRef, attribute: &Identifier, base: f64, ) -> Result<(), UnspawnedMobError>
Sets an attribute’s base value (AttributeInstance.setBaseValue), kept within the
attribute’s range.
fn add_attribute_modifier(
&self,
mob: UnspawnedMobRef,
attribute: &Identifier,
modifier: AttributeModifier,
) -> Result<(), UnspawnedMobError>
fn add_attribute_modifier( &self, mob: UnspawnedMobRef, attribute: &Identifier, modifier: AttributeModifier, ) -> Result<(), UnspawnedMobError>
Adds a permanent modifier (AttributeInstance.addPermanentModifier), saved with the mob.
fn remove_attribute_modifier(
&self,
mob: UnspawnedMobRef,
attribute: &Identifier,
id: &Identifier,
) -> Result<bool, UnspawnedMobError>
fn remove_attribute_modifier( &self, mob: UnspawnedMobRef, attribute: &Identifier, id: &Identifier, ) -> Result<bool, UnspawnedMobError>
Removes the modifier id from the attribute; false when it had none.
fn add_tag(
&self,
mob: UnspawnedMobRef,
tag: &str,
) -> Result<bool, UnspawnedMobError>
fn add_tag( &self, mob: UnspawnedMobRef, tag: &str, ) -> Result<bool, UnspawnedMobError>
Adds a tag (Entity.addTag); false when the mob has it already.
fn remove_tag(
&self,
mob: UnspawnedMobRef,
tag: &str,
) -> Result<bool, UnspawnedMobError>
fn remove_tag( &self, mob: UnspawnedMobRef, tag: &str, ) -> Result<bool, UnspawnedMobError>
Removes a tag (Entity.removeTag); false when the mob did not have it.
fn set_custom_name(
&self,
mob: UnspawnedMobRef,
name: Option<Text>,
) -> Result<(), UnspawnedMobError>
fn set_custom_name( &self, mob: UnspawnedMobRef, name: Option<Text>, ) -> Result<(), UnspawnedMobError>
Names the mob (Entity.setCustomName), or takes its name away with None.
A component deeper than 512 nodes is refused with UnspawnedMobError::Text
before changing the mob’s name.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".