pub struct FluidState {
pub fluid_id: FluidRef,
pub amount: u8,
pub falling: bool,
}Expand description
A fluid state instance with amount and falling properties.
This is computed on-demand from block states rather than stored.
Fields§
§fluid_id: FluidRefThe fluid type (water, lava, empty).
amount: u8The fluid amount (1-8, where 8 is a full block/source).
falling: boolWhether the fluid is falling (flows downward faster).
Implementations§
Source§impl FluidState
impl FluidState
Sourcepub const fn new(fluid: FluidRef, amount: u8, falling: bool) -> Self
pub const fn new(fluid: FluidRef, amount: u8, falling: bool) -> Self
Creates a new fluid state.
Sourcepub const fn source(fluid: FluidRef) -> Self
pub const fn source(fluid: FluidRef) -> Self
Creates a source fluid state (amount=8, not falling).
Sourcepub const fn flowing(fluid: FluidRef, amount: u8, falling: bool) -> Self
pub const fn flowing(fluid: FluidRef, amount: u8, falling: bool) -> Self
Creates a flowing fluid state.
Sourcepub const fn is_source(&self) -> bool
pub const fn is_source(&self) -> bool
Returns true if this is a source block (full fluid, not falling).
Checks both the registry fluid_id.is_source flag (primary discriminator,
equivalent to vanilla checking if the type is a SourceFluid) and the
data invariant amount == 8 && !falling, guarding against malformed chunk data.
Sourcepub fn own_height(&self) -> f32
pub fn own_height(&self) -> f32
Returns the fluid’s own height (0.0 to ~0.89).
Sourcepub const fn from_block_level(fluid: FluidRef, level: u8) -> Self
pub const fn from_block_level(fluid: FluidRef, level: u8) -> Self
Decodes a fluid state from a liquid block’s LEVEL property (0-15).
- LEVEL 0 = source (amount=8, falling=false)
- LEVEL 1-7 = flowing levels 7-1 (amount = 8 - level)
- LEVEL 8-15 = falling fluid (amount=8, falling=true, but clamped)
Sourcepub const fn to_block_level(self) -> u8
pub const fn to_block_level(self) -> u8
Encodes this fluid state to a liquid block’s LEVEL property (0-15).
Trait Implementations§
Source§impl Clone for FluidState
impl Clone for FluidState
Source§fn clone(&self) -> FluidState
fn clone(&self) -> FluidState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FluidState
Source§impl Debug for FluidState
impl Debug for FluidState
impl Eq for FluidState
Source§impl FluidStateExt for FluidState
impl FluidStateExt for FluidState
Source§impl PartialEq for FluidState
impl PartialEq for FluidState
Source§fn eq(&self, other: &FluidState) -> bool
fn eq(&self, other: &FluidState) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for FluidState
Auto Trait Implementations§
impl Freeze for FluidState
impl RefUnwindSafe for FluidState
impl Send for FluidState
impl Sync for FluidState
impl Unpin for FluidState
impl UnsafeUnpin for FluidState
impl UnwindSafe for FluidState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.