pub trait Mob: LivingEntity {
Show 113 methods
// Required methods
fn mob_base(&self) -> &MobBase;
fn mob_flags(&self) -> i8;
fn set_mob_flags(&self, flags: i8);
// Provided methods
fn is_saddled(&self) -> bool { ... }
fn custom_server_ai_step(&self) { ... }
fn tick_goal_selectors(&self) { ... }
fn xp_reward(&self) -> i32 { ... }
fn set_xp_reward(&self, xp_reward: i32) { ... }
fn target(&self) -> Option<SharedEntity> { ... }
fn set_target(&self, target: Option<&SharedEntity>) -> bool { ... }
fn is_valid_target(&self, target: &dyn LivingEntity) -> bool { ... }
fn can_attack(&self, target: &dyn LivingEntity) -> bool { ... }
fn base_experience_reward_mob(&self) -> i32 { ... }
fn ambient_sound_interval(&self) -> i32 { ... }
fn ambient_sound(&self) -> Option<SoundEventRef> { ... }
fn play_ambient_sound(&self) { ... }
fn reset_ambient_sound_time(&self) { ... }
fn base_tick_mob(&self) { ... }
fn mob_base_tick(&self) { ... }
fn finalize_spawn(
&self,
world: &Arc<World>,
spawn_reason: EntitySpawnReason,
group_data: Option<SpawnGroupData>,
) -> Option<SpawnGroupData> { ... }
fn finalize_spawn_mob_base(
&self,
_world: &Arc<World>,
_spawn_reason: EntitySpawnReason,
group_data: Option<SpawnGroupData>,
) -> Option<SpawnGroupData> { ... }
fn interact_mob(
&self,
player: &Player,
hand: InteractionHand,
location: DVec3,
) -> InteractionResult { ... }
fn mob_interact(
&self,
_player: &Player,
_hand: InteractionHand,
) -> InteractionResult { ... }
fn can_shear_equipment(&self, _player: &Player) -> bool { ... }
fn use_player_item(&self, player: &Player, hand: InteractionHand) { ... }
fn remove_when_far_away(&self, dist_sqr: f64) -> bool { ... }
fn requires_custom_persistence(&self) -> bool { ... }
fn is_persistence_required(&self) -> bool { ... }
fn set_persistence_required(&self) { ... }
fn can_pick_up_loot(&self) -> bool { ... }
fn set_can_pick_up_loot(&self, can_pick_up_loot: bool) { ... }
fn equipment_drop_chance(&self, slot: EquipmentSlot) -> f32 { ... }
fn is_equipment_drop_preserved(&self, slot: EquipmentSlot) -> bool { ... }
fn set_guaranteed_drop(&self, slot: EquipmentSlot) { ... }
fn drop_custom_death_loot_mob(
&self,
_source: &DamageSource,
killed_by_player: bool,
) { ... }
fn save_mob(&self, nbt: &mut NbtCompound) { ... }
fn load_mob(&self, nbt: BorrowedNbtCompoundView<'_, '_>) { ... }
fn set_death_loot_table(&self, loot_table: Option<Identifier>) { ... }
fn set_death_loot_table_seed(&self, seed: i64) { ... }
fn custom_death_loot_table(&self) -> Option<LootTableRef> { ... }
fn has_custom_death_loot_table(&self) -> bool { ... }
fn death_loot_table_seed(&self) -> i64 { ... }
fn clear_custom_death_loot_table(&self) { ... }
fn is_leashed(&self) -> bool { ... }
fn may_be_leashed(&self) -> bool { ... }
fn leash_holder(&self) -> Option<SharedEntity> { ... }
fn leash_attachment(&self) -> Option<LeashAttachment> { ... }
fn set_delayed_leash_attachment(&self, attachment: LeashAttachment) { ... }
fn can_be_leashed(&self) -> bool { ... }
fn leash_distance_to(&self, holder: &dyn Entity) -> f64 { ... }
fn leash_snap_distance(&self) -> f64 { ... }
fn leash_elastic_distance(&self) -> f64 { ... }
fn when_leashed_to(&self, holder: &dyn Entity) { ... }
fn leash_too_far_behaviour(&self) { ... }
fn on_elastic_leash_pull(&self) { ... }
fn close_range_leash_behaviour(&self, _holder: &dyn Entity) { ... }
fn check_elastic_interactions(&self, holder: &dyn Entity) -> bool { ... }
fn apply_leash_angular_momentum(&self) -> bool { ... }
fn rotate_by_leash_angular_momentum(&self, angular_momentum: f64) { ... }
fn leash_angular_momentum(&self) -> Option<f64> { ... }
fn leash_angular_friction(&self) -> f64 { ... }
fn can_have_a_leash_attached_to(&self, holder: &dyn Entity) -> bool { ... }
fn set_leashed_to(&self, holder: &SharedEntity) -> bool { ... }
fn tick_leash(&self) { ... }
fn drop_leash(&self) { ... }
fn remove_leash(&self) { ... }
fn remove_leash_state(&self) -> Option<SharedEntity> { ... }
fn is_within_home(&self) -> bool { ... }
fn is_within_home_pos(&self, pos: BlockPos) -> bool { ... }
fn is_within_home_vec(&self, pos: DVec3) -> bool { ... }
fn set_home_to(&self, position: BlockPos, radius: i32) { ... }
fn home_position(&self) -> BlockPos { ... }
fn home_radius(&self) -> i32 { ... }
fn clear_home(&self) { ... }
fn has_home(&self) -> bool { ... }
fn check_mob_despawn(&self) { ... }
fn nearest_player_distance_sqr(&self) -> Option<f64> { ... }
fn controlling_passenger_mob(&self) -> Option<SharedEntity> { ... }
fn get_pathfinding_malus(&self, path_type: PathType) -> f32 { ... }
fn max_fall_distance(&self) -> i32 { ... }
fn set_pathfinding_malus(&self, path_type: PathType, malus: f32) { ... }
fn is_no_ai(&self) -> bool { ... }
fn set_no_ai(&self, no_ai: bool) { ... }
fn is_left_handed(&self) -> bool { ... }
fn set_left_handed(&self, left_handed: bool) { ... }
fn is_aggressive(&self) -> bool { ... }
fn max_head_x_rot(&self) -> f32 { ... }
fn max_head_y_rot(&self) -> f32 { ... }
fn do_hurt_target(&self, world: &World, target: &SharedEntity) -> bool { ... }
fn mob_attack_damage_source(
&self,
weapon_item: &ItemStack,
attacker: &dyn LivingEntity,
) -> DamageSource { ... }
fn get_attack_knockback(
&self,
target: &dyn Entity,
weapon_item: &ItemStack,
damage_source: &DamageSource,
) -> f64 { ... }
fn cause_extra_knockback(
&self,
target: &dyn Entity,
knockback_amount: f64,
_old_movement: DVec3,
) { ... }
fn play_attack_sound(&self) { ... }
fn is_within_melee_attack_range(&self, target: &dyn LivingEntity) -> bool { ... }
fn attack_bounding_box(&self, horizontal_expansion: f64) -> WorldAabb { ... }
fn set_aggressive(&self, aggressive: bool) { ... }
fn set_mob_flag(&self, flag: i8, enabled: bool) { ... }
fn controlled_mob_vehicle(&self) -> Option<SharedEntity> { ... }
fn set_wanted_position(&self, position: DVec3, speed_modifier: f64) { ... }
fn jump_control_jump(&self) { ... }
fn set_mob_speed(&self, speed: f32) { ... }
fn mob_server_ai_step(&self) { ... }
fn tick_path_navigation(&self) { ... }
fn tick_move_control(&self) { ... }
fn tick_move_to_control(&self, wanted_position: DVec3, speed_modifier: f64) { ... }
fn tick_strafe_control(&self, forward: f32, right: f32) { ... }
fn is_strafe_walkable(&self, dx: f32, dz: f32) -> bool { ... }
fn tick_jumping_control(&self, speed_modifier: f64) { ... }
fn tick_look_control(&self) { ... }
fn clamp_head_rotation_to_body_when_pathing(&self) { ... }
fn tick_jump_control(&self) { ... }
fn update_control_flags(&self) { ... }
fn tick_body_rotation_control(&self) { ... }
}Required Methods§
fn mob_base(&self) -> &MobBase
fn mob_flags(&self) -> i8
fn set_mob_flags(&self, flags: i8)
Provided Methods§
Sourcefn is_saddled(&self) -> bool
fn is_saddled(&self) -> bool
Returns vanilla Mob.isSaddled.
fn custom_server_ai_step(&self)
fn tick_goal_selectors(&self)
fn xp_reward(&self) -> i32
fn set_xp_reward(&self, xp_reward: i32)
Sourcefn target(&self) -> Option<SharedEntity>
fn target(&self) -> Option<SharedEntity>
Returns vanilla Mob.getTarget.
Sourcefn set_target(&self, target: Option<&SharedEntity>) -> bool
fn set_target(&self, target: Option<&SharedEntity>) -> bool
Sets vanilla Mob.target.
Returns false when the supplied entity is not a living entity.
fn is_valid_target(&self, target: &dyn LivingEntity) -> bool
Sourcefn can_attack(&self, target: &dyn LivingEntity) -> bool
fn can_attack(&self, target: &dyn LivingEntity) -> bool
Returns vanilla Mob.canAttack.
fn base_experience_reward_mob(&self) -> i32
fn ambient_sound_interval(&self) -> i32
fn ambient_sound(&self) -> Option<SoundEventRef>
fn play_ambient_sound(&self)
fn reset_ambient_sound_time(&self)
Sourcefn base_tick_mob(&self)
fn base_tick_mob(&self)
Runs vanilla Mob.baseTick.
Sourcefn mob_base_tick(&self)
fn mob_base_tick(&self)
Runs the mob-owned portion of vanilla Mob.baseTick.
fn finalize_spawn( &self, world: &Arc<World>, spawn_reason: EntitySpawnReason, group_data: Option<SpawnGroupData>, ) -> Option<SpawnGroupData>
fn finalize_spawn_mob_base( &self, _world: &Arc<World>, _spawn_reason: EntitySpawnReason, group_data: Option<SpawnGroupData>, ) -> Option<SpawnGroupData>
Sourcefn interact_mob(
&self,
player: &Player,
hand: InteractionHand,
location: DVec3,
) -> InteractionResult
fn interact_mob( &self, player: &Player, hand: InteractionHand, location: DVec3, ) -> InteractionResult
Handles vanilla Mob.interact.
Sourcefn mob_interact(
&self,
_player: &Player,
_hand: InteractionHand,
) -> InteractionResult
fn mob_interact( &self, _player: &Player, _hand: InteractionHand, ) -> InteractionResult
Handles vanilla Mob.mobInteract.
Sourcefn can_shear_equipment(&self, _player: &Player) -> bool
fn can_shear_equipment(&self, _player: &Player) -> bool
Returns vanilla Mob.canShearEquipment.
Sourcefn use_player_item(&self, player: &Player, hand: InteractionHand)
fn use_player_item(&self, player: &Player, hand: InteractionHand)
Applies vanilla Mob.usePlayerItem.
fn remove_when_far_away(&self, dist_sqr: f64) -> bool
fn requires_custom_persistence(&self) -> bool
fn is_persistence_required(&self) -> bool
fn set_persistence_required(&self)
Sourcefn can_pick_up_loot(&self) -> bool
fn can_pick_up_loot(&self) -> bool
Returns vanilla Mob.canPickUpLoot.
fn set_can_pick_up_loot(&self, can_pick_up_loot: bool)
fn equipment_drop_chance(&self, slot: EquipmentSlot) -> f32
fn is_equipment_drop_preserved(&self, slot: EquipmentSlot) -> bool
fn set_guaranteed_drop(&self, slot: EquipmentSlot)
fn drop_custom_death_loot_mob( &self, _source: &DamageSource, killed_by_player: bool, )
fn save_mob(&self, nbt: &mut NbtCompound)
fn load_mob(&self, nbt: BorrowedNbtCompoundView<'_, '_>)
fn set_death_loot_table(&self, loot_table: Option<Identifier>)
fn set_death_loot_table_seed(&self, seed: i64)
fn custom_death_loot_table(&self) -> Option<LootTableRef>
fn has_custom_death_loot_table(&self) -> bool
fn death_loot_table_seed(&self) -> i64
fn clear_custom_death_loot_table(&self)
fn is_leashed(&self) -> bool
fn may_be_leashed(&self) -> bool
fn leash_holder(&self) -> Option<SharedEntity>
fn leash_attachment(&self) -> Option<LeashAttachment>
fn set_delayed_leash_attachment(&self, attachment: LeashAttachment)
fn can_be_leashed(&self) -> bool
fn leash_distance_to(&self, holder: &dyn Entity) -> f64
fn leash_snap_distance(&self) -> f64
fn leash_elastic_distance(&self) -> f64
fn when_leashed_to(&self, holder: &dyn Entity)
fn leash_too_far_behaviour(&self)
fn on_elastic_leash_pull(&self)
fn close_range_leash_behaviour(&self, _holder: &dyn Entity)
fn check_elastic_interactions(&self, holder: &dyn Entity) -> bool
fn apply_leash_angular_momentum(&self) -> bool
fn rotate_by_leash_angular_momentum(&self, angular_momentum: f64)
fn leash_angular_momentum(&self) -> Option<f64>
fn leash_angular_friction(&self) -> f64
fn can_have_a_leash_attached_to(&self, holder: &dyn Entity) -> bool
fn set_leashed_to(&self, holder: &SharedEntity) -> bool
fn tick_leash(&self)
fn drop_leash(&self)
fn remove_leash(&self)
fn remove_leash_state(&self) -> Option<SharedEntity>
fn is_within_home(&self) -> bool
fn is_within_home_pos(&self, pos: BlockPos) -> bool
fn is_within_home_vec(&self, pos: DVec3) -> bool
fn set_home_to(&self, position: BlockPos, radius: i32)
fn home_position(&self) -> BlockPos
fn home_radius(&self) -> i32
fn clear_home(&self)
fn has_home(&self) -> bool
fn check_mob_despawn(&self)
fn nearest_player_distance_sqr(&self) -> Option<f64>
fn controlling_passenger_mob(&self) -> Option<SharedEntity>
fn get_pathfinding_malus(&self, path_type: PathType) -> f32
Sourcefn max_fall_distance(&self) -> i32
fn max_fall_distance(&self) -> i32
Vanilla Entity.getMaxFallDistance baseline.
fn set_pathfinding_malus(&self, path_type: PathType, malus: f32)
fn is_no_ai(&self) -> bool
fn set_no_ai(&self, no_ai: bool)
fn is_left_handed(&self) -> bool
fn set_left_handed(&self, left_handed: bool)
fn is_aggressive(&self) -> bool
Sourcefn max_head_x_rot(&self) -> f32
fn max_head_x_rot(&self) -> f32
Returns vanilla Mob.getMaxHeadXRot.
Sourcefn max_head_y_rot(&self) -> f32
fn max_head_y_rot(&self) -> f32
Returns vanilla Mob.getMaxHeadYRot.
Sourcefn do_hurt_target(&self, world: &World, target: &SharedEntity) -> bool
fn do_hurt_target(&self, world: &World, target: &SharedEntity) -> bool
Handles vanilla Mob.doHurtTarget.
Sourcefn mob_attack_damage_source(
&self,
weapon_item: &ItemStack,
attacker: &dyn LivingEntity,
) -> DamageSource
fn mob_attack_damage_source( &self, weapon_item: &ItemStack, attacker: &dyn LivingEntity, ) -> DamageSource
Returns the damage source used by vanilla ItemStack.getDamageSource.
Sourcefn get_attack_knockback(
&self,
target: &dyn Entity,
weapon_item: &ItemStack,
damage_source: &DamageSource,
) -> f64
fn get_attack_knockback( &self, target: &dyn Entity, weapon_item: &ItemStack, damage_source: &DamageSource, ) -> f64
Returns vanilla LivingEntity.getKnockback for mob attacks.
Sourcefn cause_extra_knockback(
&self,
target: &dyn Entity,
knockback_amount: f64,
_old_movement: DVec3,
)
fn cause_extra_knockback( &self, target: &dyn Entity, knockback_amount: f64, _old_movement: DVec3, )
Applies vanilla LivingEntity.causeExtraKnockback.
Sourcefn play_attack_sound(&self)
fn play_attack_sound(&self)
Plays vanilla LivingEntity.playAttackSound.
Sourcefn is_within_melee_attack_range(&self, target: &dyn LivingEntity) -> bool
fn is_within_melee_attack_range(&self, target: &dyn LivingEntity) -> bool
Returns vanilla Mob.isWithinMeleeAttackRange.
Sourcefn attack_bounding_box(&self, horizontal_expansion: f64) -> WorldAabb
fn attack_bounding_box(&self, horizontal_expansion: f64) -> WorldAabb
Returns vanilla Mob.getAttackBoundingBox.
fn set_aggressive(&self, aggressive: bool)
fn set_mob_flag(&self, flag: i8, enabled: bool)
fn controlled_mob_vehicle(&self) -> Option<SharedEntity>
fn set_wanted_position(&self, position: DVec3, speed_modifier: f64)
fn jump_control_jump(&self)
Sourcefn set_mob_speed(&self, speed: f32)
fn set_mob_speed(&self, speed: f32)
Mirrors vanilla Mob.setSpeed: update cached speed and forward AI input.
fn mob_server_ai_step(&self)
fn tick_move_control(&self)
fn tick_move_to_control(&self, wanted_position: DVec3, speed_modifier: f64)
fn tick_strafe_control(&self, forward: f32, right: f32)
fn is_strafe_walkable(&self, dx: f32, dz: f32) -> bool
fn tick_jumping_control(&self, speed_modifier: f64)
fn tick_look_control(&self)
fn clamp_head_rotation_to_body_when_pathing(&self)
fn tick_jump_control(&self)
fn update_control_flags(&self)
fn tick_body_rotation_control(&self)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".