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§
Sourcefn animal_base(&self) -> &AnimalBase
fn animal_base(&self) -> &AnimalBase
Returns shared animal runtime state.
Provided Methods§
Sourcefn in_love_time(&self) -> i32
fn in_love_time(&self) -> i32
Returns vanilla Animal.inLove.
Sourcefn set_in_love_time(&self, in_love: i32)
fn set_in_love_time(&self, in_love: i32)
Sets vanilla Animal.inLove.
Sourcefn love_cause_uuid(&self) -> Option<Uuid>
fn love_cause_uuid(&self) -> Option<Uuid>
Returns vanilla Animal.loveCause as a persisted UUID.
Sourcefn set_love_cause_uuid(&self, love_cause: Option<Uuid>)
fn set_love_cause_uuid(&self, love_cause: Option<Uuid>)
Sets vanilla Animal.loveCause as a persisted UUID.
Sourcefn is_in_love(&self) -> bool
fn is_in_love(&self) -> bool
Returns vanilla Animal.isInLove.
Sourcefn can_fall_in_love(&self) -> bool
fn can_fall_in_love(&self) -> bool
Returns vanilla Animal.canFallInLove.
Sourcefn set_in_love(&self, player: Option<&Player>)
fn set_in_love(&self, player: Option<&Player>)
Sets vanilla love mode and records the player that caused it.
Sourcefn reset_love(&self)
fn reset_love(&self)
Resets vanilla love mode without clearing the stored love cause.
Sourcefn is_food(&self, _item_stack: &ItemStack) -> bool
fn is_food(&self, _item_stack: &ItemStack) -> bool
Returns whether the stack is valid food for this animal.
Sourcefn base_experience_reward_animal(&self) -> i32
fn base_experience_reward_animal(&self) -> i32
Returns vanilla Animal.getBaseExperienceReward.
Sourcefn ambient_sound_interval_animal(&self) -> i32
fn ambient_sound_interval_animal(&self) -> i32
Returns vanilla Animal.getAmbientSoundInterval.
Sourcefn animal_walk_target_value(&self, pos: BlockPos) -> f32
fn animal_walk_target_value(&self, pos: BlockPos) -> f32
Returns vanilla Animal.getWalkTargetValue.
Sourcefn is_bright_enough_to_spawn(level: &dyn LevelReader, pos: BlockPos) -> boolwhere
Self: Sized,
fn is_bright_enough_to_spawn(level: &dyn LevelReader, pos: BlockPos) -> boolwhere
Self: Sized,
Returns vanilla Animal.isBrightEnoughToSpawn.
Sourcefn check_animal_spawn_rules(
level: &dyn LevelReader,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
) -> boolwhere
Self: Sized,
fn check_animal_spawn_rules(
level: &dyn LevelReader,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
) -> boolwhere
Self: Sized,
Returns vanilla Animal.checkAnimalSpawnRules.
Sourcefn play_eating_sound(&self)
fn play_eating_sound(&self)
Plays this animal’s vanilla eating sound.
Sourcefn mob_interact_animal(
&self,
player: &Player,
hand: InteractionHand,
) -> InteractionResult
fn mob_interact_animal( &self, player: &Player, hand: InteractionHand, ) -> InteractionResult
Handles vanilla Animal.mobInteract.
Sourcefn create_breed_offspring(&self, world: &Arc<World>) -> Option<SharedEntity>
fn create_breed_offspring(&self, world: &Arc<World>) -> Option<SharedEntity>
Creates a same-type offspring using the registered entity factory.
Sourcefn breed_variant_key(&self) -> Option<&Identifier>
fn breed_variant_key(&self) -> Option<&Identifier>
Returns this animal’s breedable variant key when offspring inherit it.
Sourcefn set_breed_variant_key(&self, _key: &Identifier) -> bool
fn set_breed_variant_key(&self, _key: &Identifier) -> bool
Applies a breedable variant key to offspring that inherit one.
Sourcefn initialize_breed_offspring(
&self,
_partner: &dyn Animal,
_offspring: &dyn Animal,
)
fn initialize_breed_offspring( &self, _partner: &dyn Animal, _offspring: &dyn Animal, )
Applies entity-specific state to freshly created breeding offspring.
Sourcefn get_breed_offspring(
&self,
world: &Arc<World>,
partner: &dyn Animal,
) -> Option<SharedEntity>
fn get_breed_offspring( &self, world: &Arc<World>, partner: &dyn Animal, ) -> Option<SharedEntity>
Creates this animal’s vanilla breeding offspring.
Sourcefn spawn_child_from_breeding(&self, world: &Arc<World>, partner: &dyn Animal)
fn spawn_child_from_breeding(&self, world: &Arc<World>, partner: &dyn Animal)
Creates, initializes, and inserts vanilla breeding offspring.
Sourcefn finalize_spawn_child_from_breeding(
&self,
world: &Arc<World>,
partner: &dyn Animal,
_offspring: Option<&dyn Animal>,
)
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.
Sourcefn tick_animal_love(&self)
fn tick_animal_love(&self)
Ticks vanilla animal love state.
Sourcefn custom_server_ai_step_animal(&self)
fn custom_server_ai_step_animal(&self)
Runs vanilla Animal.customServerAiStep.
Sourcefn remove_when_far_away_animal(&self, _dist_sqr: f64) -> bool
fn remove_when_far_away_animal(&self, _dist_sqr: f64) -> bool
Returns vanilla animal far-away despawn behavior.
Sourcefn save_animal(&self, nbt: &mut NbtCompound)
fn save_animal(&self, nbt: &mut NbtCompound)
Saves vanilla animal fields.
Sourcefn load_animal(&self, nbt: BorrowedNbtCompoundView<'_, '_>)
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".