Skip to main content

Animal

Trait Animal 

Source
pub trait Animal: AgeableMob {
Show 30 methods // Required method fn animal_base(&self) -> &AnimalBase; // Provided methods fn in_love_time(&self) -> i32 { ... } fn set_in_love_time(&self, in_love: i32) { ... } fn love_cause_uuid(&self) -> Option<Uuid> { ... } fn set_love_cause_uuid(&self, love_cause: Option<Uuid>) { ... } fn is_in_love(&self) -> bool { ... } fn can_fall_in_love(&self) -> bool { ... } fn set_in_love(&self, player: Option<&Player>) { ... } fn reset_love(&self) { ... } fn can_mate(&self, partner: &dyn Animal) -> bool { ... } fn is_food(&self, _item_stack: &ItemStack) -> bool { ... } fn base_experience_reward_animal(&self) -> i32 { ... } fn ambient_sound_interval_animal(&self) -> i32 { ... } fn animal_walk_target_value(&self, pos: BlockPos) -> f32 { ... } fn is_bright_enough_to_spawn(level: &dyn LevelReader, pos: BlockPos) -> bool where Self: Sized { ... } fn check_animal_spawn_rules( level: &dyn LevelReader, spawn_reason: EntitySpawnReason, pos: BlockPos, ) -> bool where Self: Sized { ... } fn play_eating_sound(&self) { ... } fn mob_interact_animal( &self, player: &Player, hand: InteractionHand, ) -> InteractionResult { ... } fn create_breed_offspring(&self, world: &Arc<World>) -> Option<SharedEntity> { ... } fn breed_variant_key(&self) -> Option<&Identifier> { ... } fn set_breed_variant_key(&self, _key: &Identifier) -> bool { ... } fn initialize_breed_offspring( &self, _partner: &dyn Animal, _offspring: &dyn Animal, ) { ... } fn get_breed_offspring( &self, world: &Arc<World>, partner: &dyn Animal, ) -> Option<SharedEntity> { ... } fn spawn_child_from_breeding( &self, world: &Arc<World>, partner: &dyn Animal, ) { ... } fn finalize_spawn_child_from_breeding( &self, world: &Arc<World>, partner: &dyn Animal, _offspring: Option<&dyn Animal>, ) { ... } fn tick_animal_love(&self) { ... } fn custom_server_ai_step_animal(&self) { ... } fn remove_when_far_away_animal(&self, _dist_sqr: f64) -> bool { ... } fn save_animal(&self, nbt: &mut NbtCompound) { ... } fn load_animal(&self, nbt: BorrowedNbtCompoundView<'_, '_>) { ... }
}
Expand description

Vanilla-shaped behavior shared by entities that extend Animal.

Required Methods§

Source

fn animal_base(&self) -> &AnimalBase

Returns shared animal runtime state.

Provided Methods§

Source

fn in_love_time(&self) -> i32

Returns vanilla Animal.inLove.

Source

fn set_in_love_time(&self, in_love: i32)

Sets vanilla Animal.inLove.

Source

fn love_cause_uuid(&self) -> Option<Uuid>

Returns vanilla Animal.loveCause as a persisted UUID.

Source

fn set_love_cause_uuid(&self, love_cause: Option<Uuid>)

Sets vanilla Animal.loveCause as a persisted UUID.

Source

fn is_in_love(&self) -> bool

Returns vanilla Animal.isInLove.

Source

fn can_fall_in_love(&self) -> bool

Returns vanilla Animal.canFallInLove.

Source

fn set_in_love(&self, player: Option<&Player>)

Sets vanilla love mode and records the player that caused it.

Source

fn reset_love(&self)

Resets vanilla love mode without clearing the stored love cause.

Source

fn can_mate(&self, partner: &dyn Animal) -> bool

Returns vanilla Animal.canMate.

Source

fn is_food(&self, _item_stack: &ItemStack) -> bool

Returns whether the stack is valid food for this animal.

Source

fn base_experience_reward_animal(&self) -> i32

Returns vanilla Animal.getBaseExperienceReward.

Source

fn ambient_sound_interval_animal(&self) -> i32

Returns vanilla Animal.getAmbientSoundInterval.

Source

fn animal_walk_target_value(&self, pos: BlockPos) -> f32

Returns vanilla Animal.getWalkTargetValue.

Source

fn is_bright_enough_to_spawn(level: &dyn LevelReader, pos: BlockPos) -> bool
where Self: Sized,

Returns vanilla Animal.isBrightEnoughToSpawn.

Source

fn check_animal_spawn_rules( level: &dyn LevelReader, spawn_reason: EntitySpawnReason, pos: BlockPos, ) -> bool
where Self: Sized,

Returns vanilla Animal.checkAnimalSpawnRules.

Source

fn play_eating_sound(&self)

Plays this animal’s vanilla eating sound.

Source

fn mob_interact_animal( &self, player: &Player, hand: InteractionHand, ) -> InteractionResult

Handles vanilla Animal.mobInteract.

Source

fn create_breed_offspring(&self, world: &Arc<World>) -> Option<SharedEntity>

Creates a same-type offspring using the registered entity factory.

Source

fn breed_variant_key(&self) -> Option<&Identifier>

Returns this animal’s breedable variant key when offspring inherit it.

Source

fn set_breed_variant_key(&self, _key: &Identifier) -> bool

Applies a breedable variant key to offspring that inherit one.

Source

fn initialize_breed_offspring( &self, _partner: &dyn Animal, _offspring: &dyn Animal, )

Applies entity-specific state to freshly created breeding offspring.

Source

fn get_breed_offspring( &self, world: &Arc<World>, partner: &dyn Animal, ) -> Option<SharedEntity>

Creates this animal’s vanilla breeding offspring.

Source

fn spawn_child_from_breeding(&self, world: &Arc<World>, partner: &dyn Animal)

Creates, initializes, and inserts vanilla breeding offspring.

Source

fn finalize_spawn_child_from_breeding( &self, world: &Arc<World>, partner: &dyn Animal, _offspring: Option<&dyn Animal>, )

Applies vanilla breeding side effects after offspring creation.

Source

fn tick_animal_love(&self)

Ticks vanilla animal love state.

Source

fn custom_server_ai_step_animal(&self)

Runs vanilla Animal.customServerAiStep.

Source

fn remove_when_far_away_animal(&self, _dist_sqr: f64) -> bool

Returns vanilla animal far-away despawn behavior.

Source

fn save_animal(&self, nbt: &mut NbtCompound)

Saves vanilla animal fields.

Source

fn load_animal(&self, nbt: BorrowedNbtCompoundView<'_, '_>)

Loads vanilla animal fields.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§