steel_core/behavior/blocks/decoration/
weathering_lantern_block.rs1use std::sync::Arc;
2
3use steel_macros::block_behavior;
4use steel_registry::blocks::BlockRef;
5use steel_utils::{BlockPos, BlockStateId, Direction};
6
7use crate::{
8 behavior::{
9 BlockBehavior, BlockPlaceContext,
10 blocks::{LanternBlock, WeatherState, WeatheringCopper},
11 },
12 entity::ai::path::PathComputationType,
13 world::{LevelReader, ScheduledTickAccess, World},
14};
15
16#[block_behavior]
18pub struct WeatheringLanternBlock {
19 lantern: LanternBlock,
20 #[json_arg(r#enum = "WeatherState", json = "weather_state")]
21 weathering: WeatheringCopper,
22}
23
24impl WeatheringLanternBlock {
25 #[must_use]
27 pub const fn new(block: BlockRef, weather_state: WeatherState) -> Self {
28 Self {
29 lantern: LanternBlock::new(block),
30 weathering: WeatheringCopper::new(weather_state),
31 }
32 }
33}
34
35impl BlockBehavior for WeatheringLanternBlock {
36 fn random_tick(&self, state: BlockStateId, world: &Arc<World>, pos: BlockPos) {
37 self.weathering.change_over_time(state, world, pos);
38 }
39
40 fn get_state_for_placement(&self, context: &BlockPlaceContext<'_>) -> Option<BlockStateId> {
41 self.lantern.get_state_for_placement(context)
42 }
43
44 fn can_survive(&self, state: BlockStateId, world: &dyn LevelReader, pos: BlockPos) -> bool {
45 self.lantern.can_survive(state, world, pos)
46 }
47
48 fn update_shape(
49 &self,
50 state: BlockStateId,
51 world: &dyn ScheduledTickAccess,
52 pos: BlockPos,
53 direction: Direction,
54 neighbor_pos: BlockPos,
55 neighbor_state: BlockStateId,
56 ) -> BlockStateId {
57 self.lantern
58 .update_shape(state, world, pos, direction, neighbor_pos, neighbor_state)
59 }
60
61 fn is_pathfindable(&self, state: BlockStateId, computation_type: PathComputationType) -> bool {
62 self.lantern.is_pathfindable(state, computation_type)
63 }
64}