steel_core/worldgen/feature/features/
freeze_top_layer.rs1use super::super::prelude::*;
2use super::super::runner::FeatureDecorationRunner;
3
4impl FeatureDecorationRunner {
5 pub(in crate::worldgen::feature) fn place_freeze_top_layer_feature(
6 region: &mut WorldGenRegion<'_>,
7 registry: &Registry,
8 origin: BlockPos,
9 biome_zoom_seed: i64,
10 ) -> bool {
11 let ice = vanilla_blocks::ICE.default_state();
12 let snow = vanilla_blocks::SNOW.default_state();
13
14 for dx in 0..16 {
15 for dz in 0..16 {
16 let x = origin.x() + dx;
17 let z = origin.z() + dz;
18 let y = region.height_at(HeightmapType::MotionBlocking, x, z);
19 let top_pos = BlockPos::new(x, y, z);
20 let below_pos = top_pos.below();
21 let biome = Self::biome_at_block(region, registry, biome_zoom_seed, top_pos);
22
23 if Self::should_freeze_in_biome(region, biome, below_pos, false) {
24 let _ = region.set_block_state(below_pos, ice, UpdateFlags::UPDATE_CLIENTS);
25 }
26
27 if Self::should_snow_in_biome(region, biome, top_pos) {
28 let _ = region.set_block_state(top_pos, snow, UpdateFlags::UPDATE_CLIENTS);
29 Self::set_snowy_below(region, below_pos);
30 }
31 }
32 }
33
34 true
35 }
36
37 fn set_snowy_below(region: &mut WorldGenRegion<'_>, below_pos: BlockPos) {
38 let below_state = region.block_state(below_pos);
39 if below_state
40 .try_get_value(&BlockStateProperties::SNOWY)
41 .is_none()
42 {
43 return;
44 }
45
46 let snowy_state = below_state.set_value(&BlockStateProperties::SNOWY, true);
47 let _ = region.set_block_state(below_pos, snowy_state, UpdateFlags::UPDATE_CLIENTS);
48 }
49}