Skip to main content

steel_core/worldgen/feature/features/
vines.rs

1use super::super::prelude::*;
2use super::super::runner::FeatureDecorationRunner;
3
4impl FeatureDecorationRunner {
5    pub(in crate::worldgen::feature) fn place_vines_feature(
6        region: &mut WorldGenRegion<'_>,
7        origin: BlockPos,
8    ) -> bool {
9        if !region.block_state(origin).is_air() {
10            return false;
11        }
12
13        for direction in Self::VANILLA_DIRECTION_VALUES {
14            if direction == Direction::Down {
15                continue;
16            }
17
18            if Self::can_attach_to_multiface(region, origin, direction) {
19                let _ = region.set_block_state(
20                    origin,
21                    Self::vine_state_for_face(direction),
22                    UpdateFlags::UPDATE_CLIENTS,
23                );
24                return true;
25            }
26        }
27
28        false
29    }
30
31    pub(in crate::worldgen::feature) fn vine_state_for_face(direction: Direction) -> BlockStateId {
32        let vine = vanilla_blocks::VINE.default_state();
33        match direction {
34            Direction::Up => vine.set_value(&BlockStateProperties::UP, true),
35            Direction::North => vine.set_value(&BlockStateProperties::NORTH, true),
36            Direction::South => vine.set_value(&BlockStateProperties::SOUTH, true),
37            Direction::West => vine.set_value(&BlockStateProperties::WEST, true),
38            Direction::East => vine.set_value(&BlockStateProperties::EAST, true),
39            Direction::Down => {
40                panic!("vine has no face property for downward attachment")
41            }
42        }
43    }
44}