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§
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)
Sourcefn swim_splash_sound_monster(&self) -> SoundEventRef
fn swim_splash_sound_monster(&self) -> SoundEventRef
Returns the hostile water-entry splash sound.
Sourcefn swim_sound_monster(&self) -> SoundEventRef
fn swim_sound_monster(&self) -> SoundEventRef
Returns the hostile swim sound.
Sourcefn update_no_action_time(&self)
fn update_no_action_time(&self)
Adds two idle ticks in bright light to hasten despawning.
fn monster_ai_step(&self, entity: &SharedEntity) -> Option<MoveResult>
Sourcefn get_walk_target_value_monster(&self, pos: BlockPos) -> f32
fn get_walk_target_value_monster(&self, pos: BlockPos) -> f32
Favors darker positions for pathfinding.
fn is_preventing_player_rest(&self, _level: &World, _player: &Player) -> bool
fn should_drop_experience_monster(&self) -> bool
Sourcefn should_drop_loot_monster(&self, world: &World) -> bool
fn should_drop_loot_monster(&self, world: &World) -> bool
Allows loot when mobDrops is enabled, including for babies.
Sourcefn is_dark_enough_to_spawn(
level: &World,
pos: BlockPos,
random: &mut impl Random,
) -> boolwhere
Self: Sized,
fn is_dark_enough_to_spawn(
level: &World,
pos: BlockPos,
random: &mut impl Random,
) -> boolwhere
Self: Sized,
Checks dimension light limits using the caller’s seeded RNG.
Sourcefn check_monster_spawn_rules(
entity_type: EntityTypeRef,
level: &World,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
random: &mut impl Random,
) -> boolwhere
Self: Sized,
fn check_monster_spawn_rules(
entity_type: EntityTypeRef,
level: &World,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
random: &mut impl Random,
) -> boolwhere
Self: Sized,
Checks difficulty, light, and the spawn surface.
Sourcefn check_any_light_monster_spawn_rules(
entity_type: EntityTypeRef,
level: &World,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
) -> boolwhere
Self: Sized,
fn check_any_light_monster_spawn_rules(
entity_type: EntityTypeRef,
level: &World,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
) -> boolwhere
Self: Sized,
Checks difficulty and the spawn surface without a light requirement.
Sourcefn check_surface_monsters_spawn_rules(
entity_type: EntityTypeRef,
level: &World,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
random: &mut impl Random,
) -> boolwhere
Self: Sized,
fn check_surface_monsters_spawn_rules(
entity_type: EntityTypeRef,
level: &World,
spawn_reason: EntitySpawnReason,
pos: BlockPos,
random: &mut impl Random,
) -> boolwhere
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".