Skip to main content

steel_core/worldgen/feature/features/
end_island.rs

1use super::super::prelude::*;
2use super::super::runner::FeatureDecorationRunner;
3
4impl FeatureDecorationRunner {
5    pub(in crate::worldgen::feature) fn place_end_island_feature(
6        region: &mut WorldGenRegion<'_>,
7        random: &mut WorldgenRandom,
8        origin: BlockPos,
9    ) -> bool {
10        let end_stone = vanilla_blocks::END_STONE.default_state();
11        let mut size = random.next_i32_bounded(3) as f32 + 4.0;
12        let mut y = 0;
13
14        while size > 0.5 {
15            for x in fast_floor(f64::from(-size))..=size.ceil() as i32 {
16                for z in fast_floor(f64::from(-size))..=size.ceil() as i32 {
17                    if (x * x + z * z) as f32 <= (size + 1.0) * (size + 1.0) {
18                        let _ = region.set_block_state(
19                            origin.offset(x, y, z),
20                            end_stone,
21                            UpdateFlags::UPDATE_CLIENTS,
22                        );
23                    }
24                }
25            }
26
27            size -= random.next_i32_bounded(2) as f32 + 0.5;
28            y -= 1;
29        }
30
31        true
32    }
33}