steel_core/entity/
spawn_placements.rs1use rand::Rng;
4use steel_registry::entity_type::EntityTypeRef;
5use steel_utils::{BlockPos, types::Difficulty};
6
7use crate::entity::{ENTITIES, EntitySpawnReason};
8use crate::world::World;
9
10pub(crate) struct SpawnPlacements;
15
16impl SpawnPlacements {
17 pub(crate) fn check_spawner_spawn_rules(
19 entity_type: EntityTypeRef,
20 world: &World,
21 pos: BlockPos,
22 random: &mut dyn Rng,
23 ) -> bool {
24 if !entity_type.allowed_in_peaceful && world.difficulty() == Difficulty::Peaceful {
25 return false;
26 }
27
28 ENTITIES
29 .spawn_rule(entity_type)
30 .is_none_or(|rule| rule(entity_type, world, EntitySpawnReason::Spawner, pos, random))
31 }
32}