Skip to main content

Monster

Trait Monster 

Source
pub trait Monster: PathfinderMob + Enemy {
Show 17 methods // Provided methods fn default_xp_reward_monster(&self) -> i32 { ... } fn sound_source_monster(&self) -> SoundSource { ... } fn hurt_sound_monster( &self, _source: &DamageSource, ) -> Option<SoundEventRef> { ... } fn death_sound_monster(&self) -> Option<SoundEventRef> { ... } fn fall_sounds_monster(&self) -> (SoundEventRef, SoundEventRef) { ... } fn swim_splash_sound_monster(&self) -> SoundEventRef { ... } fn swim_sound_monster(&self) -> SoundEventRef { ... } fn update_no_action_time(&self) { ... } fn monster_ai_step(&self, entity: &SharedEntity) -> Option<MoveResult> { ... } fn get_walk_target_value_monster(&self, pos: BlockPos) -> f32 { ... } fn is_preventing_player_rest( &self, _level: &World, _player: &Player, ) -> bool { ... } fn should_drop_experience_monster(&self) -> bool { ... } fn should_drop_loot_monster(&self, world: &World) -> bool { ... } fn is_dark_enough_to_spawn( level: &World, pos: BlockPos, random: &mut impl Random, ) -> bool where Self: Sized { ... } fn check_monster_spawn_rules( entity_type: EntityTypeRef, level: &World, spawn_reason: EntitySpawnReason, pos: BlockPos, random: &mut impl Random, ) -> bool where Self: Sized { ... } fn check_any_light_monster_spawn_rules( entity_type: EntityTypeRef, level: &World, spawn_reason: EntitySpawnReason, pos: BlockPos, ) -> bool where Self: Sized { ... } fn check_surface_monsters_spawn_rules( entity_type: EntityTypeRef, level: &World, spawn_reason: EntitySpawnReason, pos: BlockPos, random: &mut impl Random, ) -> bool where Self: Sized { ... }
}
Expand description

Shared hostile-mob behavior. Concrete mobs delegate to _monster hooks to avoid name collisions with base-trait methods.

Provided Methods§

Source

fn default_xp_reward_monster(&self) -> i32

Source

fn sound_source_monster(&self) -> SoundSource

Source

fn hurt_sound_monster(&self, _source: &DamageSource) -> Option<SoundEventRef>

Source

fn death_sound_monster(&self) -> Option<SoundEventRef>

Source

fn fall_sounds_monster(&self) -> (SoundEventRef, SoundEventRef)

Source

fn swim_splash_sound_monster(&self) -> SoundEventRef

Returns the hostile water-entry splash sound.

Source

fn swim_sound_monster(&self) -> SoundEventRef

Returns the hostile swim sound.

Source

fn update_no_action_time(&self)

Adds two idle ticks in bright light to hasten despawning.

Source

fn monster_ai_step(&self, entity: &SharedEntity) -> Option<MoveResult>

Source

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

Favors darker positions for pathfinding.

Source

fn is_preventing_player_rest(&self, _level: &World, _player: &Player) -> bool

Source

fn should_drop_experience_monster(&self) -> bool

Source

fn should_drop_loot_monster(&self, world: &World) -> bool

Allows loot when mobDrops is enabled, including for babies.

Source

fn is_dark_enough_to_spawn( level: &World, pos: BlockPos, random: &mut impl Random, ) -> bool
where Self: Sized,

Checks dimension light limits using the caller’s seeded RNG.

Source

fn check_monster_spawn_rules( entity_type: EntityTypeRef, level: &World, spawn_reason: EntitySpawnReason, pos: BlockPos, random: &mut impl Random, ) -> bool
where Self: Sized,

Checks difficulty, light, and the spawn surface.

Source

fn check_any_light_monster_spawn_rules( entity_type: EntityTypeRef, level: &World, spawn_reason: EntitySpawnReason, pos: BlockPos, ) -> bool
where Self: Sized,

Checks difficulty and the spawn surface without a light requirement.

Source

fn check_surface_monsters_spawn_rules( entity_type: EntityTypeRef, level: &World, spawn_reason: EntitySpawnReason, pos: BlockPos, random: &mut impl Random, ) -> bool
where Self: Sized,

Adds sky visibility to monster spawn rules, except for spawners.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§