steel_core/worldgen/feature/features/
glowstone_blob.rs1use super::super::prelude::*;
2use super::super::runner::FeatureDecorationRunner;
3
4impl FeatureDecorationRunner {
5 pub(in crate::worldgen::feature) fn place_glowstone_blob_feature(
6 region: &mut WorldGenRegion<'_>,
7 random: &mut WorldgenRandom,
8 origin: BlockPos,
9 ) -> bool {
10 if !region.block_state(origin).is_air() {
11 return false;
12 }
13
14 let above_block = region.block_state(origin.above()).get_block();
15 if above_block != &vanilla_blocks::NETHERRACK
16 && above_block != &vanilla_blocks::BASALT
17 && above_block != &vanilla_blocks::BLACKSTONE
18 {
19 return false;
20 }
21
22 let glowstone = vanilla_blocks::GLOWSTONE.default_state();
23 let _ = region.set_block_state(origin, glowstone, UpdateFlags::UPDATE_CLIENTS);
24
25 for _ in 0..1500 {
26 let place_pos = origin.offset(
27 random.next_i32_bounded(8) - random.next_i32_bounded(8),
28 -random.next_i32_bounded(12),
29 random.next_i32_bounded(8) - random.next_i32_bounded(8),
30 );
31 if !region.block_state(place_pos).is_air() {
32 continue;
33 }
34
35 let mut neighbors = 0;
36 for direction in Self::VANILLA_DIRECTION_VALUES {
37 if region
38 .block_state(place_pos.relative(direction))
39 .get_block()
40 == &vanilla_blocks::GLOWSTONE
41 {
42 neighbors += 1;
43 }
44
45 if neighbors > 1 {
46 break;
47 }
48 }
49
50 if neighbors == 1 {
51 let _ = region.set_block_state(place_pos, glowstone, UpdateFlags::UPDATE_CLIENTS);
52 }
53 }
54
55 true
56 }
57}