steel_core/worldgen/feature/features/
sea_pickle.rs1use super::super::prelude::*;
2use super::super::runner::FeatureDecorationRunner;
3
4impl FeatureDecorationRunner {
5 pub(in crate::worldgen::feature) fn place_sea_pickle_feature(
6 region: &mut WorldGenRegion<'_>,
7 random: &mut WorldgenRandom,
8 config: &SeaPickleConfiguration,
9 origin: BlockPos,
10 ) -> bool {
11 let mut placed = 0;
12 let count = config.count.sample(random);
13
14 for _ in 0..count {
15 let x = random.next_i32_bounded(8) - random.next_i32_bounded(8);
16 let z = random.next_i32_bounded(8) - random.next_i32_bounded(8);
17 let y = region.height_at(HeightmapType::OceanFloor, origin.x() + x, origin.z() + z);
18 let pickle_pos = BlockPos::new(origin.x() + x, y, origin.z() + z);
19 let pickle_count = (random.next_i32_bounded(4) + 1) as u8;
20 let pickle_state = vanilla_blocks::SEA_PICKLE
21 .default_state()
22 .set_value(&BlockStateProperties::PICKLES, pickle_count);
23 let behavior = BLOCK_BEHAVIORS.get_behavior(&vanilla_blocks::SEA_PICKLE);
24
25 if region.block_state(pickle_pos).get_block() == &vanilla_blocks::WATER
26 && behavior.can_survive(pickle_state, region, pickle_pos)
27 {
28 let _ =
29 region.set_block_state(pickle_pos, pickle_state, UpdateFlags::UPDATE_CLIENTS);
30 placed += 1;
31 }
32 }
33
34 placed > 0
35 }
36}