steel_core/worldgen/feature/features/
end_gateway.rs1use super::super::prelude::*;
2use super::super::runner::FeatureDecorationRunner;
3
4impl FeatureDecorationRunner {
5 pub(in crate::worldgen::feature) fn place_end_gateway_feature(
6 region: &WorldGenRegion<'_>,
7 config: &EndGatewayConfiguration,
8 origin: BlockPos,
9 ) -> bool {
10 for dy in -2..=2 {
11 for dx in -1..=1 {
12 for dz in -1..=1 {
13 let pos = origin.offset(dx, dy, dz);
14 let same_x = dx == 0;
15 let same_y = dy == 0;
16 let same_z = dz == 0;
17 let end = dy.abs() == 2;
18 if same_x && same_y && same_z {
19 let state = vanilla_blocks::END_GATEWAY.default_state();
20 let _ = region.set_block_state(pos, state, UpdateFlags::UPDATE_ALL);
21 let exit = config.exit.map(BlockPos);
22 Self::set_end_gateway_block_entity(region, pos, state, exit, config.exact);
23 } else if same_y {
24 let _ = region.set_block_state(
25 pos,
26 vanilla_blocks::AIR.default_state(),
27 UpdateFlags::UPDATE_ALL,
28 );
29 } else if (end && same_x && same_z) || ((same_x || same_z) && !end) {
30 let _ = region.set_block_state(
31 pos,
32 vanilla_blocks::BEDROCK.default_state(),
33 UpdateFlags::UPDATE_ALL,
34 );
35 } else {
36 let _ = region.set_block_state(
37 pos,
38 vanilla_blocks::AIR.default_state(),
39 UpdateFlags::UPDATE_ALL,
40 );
41 }
42 }
43 }
44 }
45
46 true
47 }
48}