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::items::ItemRef;
11use steel_registry::{vanilla_blocks, vanilla_fluids, vanilla_items};
12use steel_utils::types::{BlockPos, BlockStateId};
13
14use crate::fluid::FluidBehavior;
15use crate::fluid::FluidState;
16use crate::world::World;
17
18/// Empty fluid behavior - represents the absence of fluid.
19pub struct EmptyFluid;
20
21impl FluidBehavior for EmptyFluid {
22    fn create_legacy_block(&self, _fluid_state: FluidState) -> BlockStateId {
23        vanilla_blocks::AIR.default_state()
24    }
25
26    fn bucket(&self) -> ItemRef {
27        &vanilla_items::AIR
28    }
29
30    fn fluid_type(&self) -> FluidRef {
31        &vanilla_fluids::EMPTY
32    }
33
34    fn tick(
35        &self,
36        _world: &Arc<World>,
37        _pos: BlockPos,
38        _block_state: BlockStateId,
39        _fluid_state: FluidState,
40    ) {
41        // Vanilla: nothing
42    }
43
44    fn spread(
45        &self,
46        _world: &Arc<World>,
47        _pos: BlockPos,
48        _block_state: BlockStateId,
49        _fluid_state: FluidState,
50    ) {
51        // Vanilla: nothing
52    }
53
54    fn tick_delay(&self, _world: &Arc<World>) -> i32 {
55        0
56    }
57
58    fn drop_off(&self, _world: &Arc<World>) -> u8 {
59        0
60    }
61
62    fn slope_find_distance(&self, _world: &Arc<World>) -> u8 {
63        0
64    }
65
66    /// Returns true if empty can be replaced by another fluid.
67    /// Based on vanilla `EmptyFluid.canBeReplacedWith()`.
68    /// Empty can always be replaced.
69    fn can_be_replaced_with(
70        &self,
71        _fluid_state: FluidState,
72        _world: &Arc<World>,
73        _pos: BlockPos,
74        _other_fluid: FluidRef,
75        _direction: Direction,
76    ) -> bool {
77        // Empty can always be replaced by any fluid
78        true
79    }
80}