Skip to main content

steel_core/fluid/fluids/
empty.rs

1//! Empty fluid implementation.
2//!
3//! Represents the absence of fluid in a block space.
4//!
5
6use std::sync::Arc;
7
8use steel_registry::blocks::properties::Direction;
9use steel_registry::fluid::FluidRef;
10use steel_registry::vanilla_fluids;
11use steel_utils::types::{BlockPos, BlockStateId};
12
13use crate::fluid::FluidBehavior;
14use crate::fluid::FluidState;
15use crate::world::World;
16
17/// Empty fluid behavior - represents the absence of fluid.
18pub struct EmptyFluid;
19
20impl FluidBehavior for EmptyFluid {
21    fn fluid_type(&self) -> FluidRef {
22        &vanilla_fluids::EMPTY
23    }
24
25    fn tick(
26        &self,
27        _world: &Arc<World>,
28        _pos: BlockPos,
29        _block_state: BlockStateId,
30        _fluid_state: FluidState,
31    ) {
32        // Vanilla: nothing
33    }
34
35    fn spread(
36        &self,
37        _world: &Arc<World>,
38        _pos: BlockPos,
39        _block_state: BlockStateId,
40        _fluid_state: FluidState,
41    ) {
42        // Vanilla: nothing
43    }
44
45    fn tick_delay(&self, _world: &Arc<World>) -> i32 {
46        0
47    }
48
49    fn drop_off(&self, _world: &Arc<World>) -> u8 {
50        0
51    }
52
53    fn slope_find_distance(&self, _world: &Arc<World>) -> u8 {
54        0
55    }
56
57    /// Returns true if empty can be replaced by another fluid.
58    /// Based on vanilla `EmptyFluid.canBeReplacedWith()`.
59    /// Empty can always be replaced.
60    fn can_be_replaced_with(
61        &self,
62        _fluid_state: FluidState,
63        _world: &Arc<World>,
64        _pos: BlockPos,
65        _other_fluid: FluidRef,
66        _direction: Direction,
67    ) -> bool {
68        // Empty can always be replaced by any fluid
69        true
70    }
71}