steel_core/behavior/blocks/vegetation/
nether_fungus_block.rs1use steel_macros::block_behavior;
2use steel_registry::{vanilla_block_tags::BlockTag, vanilla_blocks};
3use steel_utils::{BlockPos, BlockStateId};
4
5use crate::behavior::block::BlockBehavior;
6use crate::behavior::context::BlockPlaceContext;
7use crate::world::LevelReader;
8
9use super::{BlockRef, default_surviving_state, survives_on_tag};
10
11#[block_behavior]
14pub struct NetherFungusBlock {
15 block: BlockRef,
16}
17
18impl NetherFungusBlock {
19 #[must_use]
21 pub const fn new(block: BlockRef) -> Self {
22 Self { block }
23 }
24
25 fn support_tag(&self) -> steel_utils::Identifier {
26 if self.block == &vanilla_blocks::WARPED_FUNGUS {
27 BlockTag::SUPPORTS_WARPED_FUNGUS
28 } else {
29 BlockTag::SUPPORTS_CRIMSON_FUNGUS
30 }
31 }
32}
33
34impl BlockBehavior for NetherFungusBlock {
35 fn can_survive(&self, _state: BlockStateId, world: &dyn LevelReader, pos: BlockPos) -> bool {
36 let support_tag = self.support_tag();
37 survives_on_tag(world, pos, &support_tag)
38 }
39
40 fn get_state_for_placement(&self, context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
41 default_surviving_state(self.block, self, context)
42 }
43}