Struct FluidState
pub(in worldgen::feature) struct FluidState {
pub fluid_id: &'static Fluid,
pub amount: u8,
pub falling: bool,
}Expand description
A fluid state instance with amount and falling properties.
Registered block states cache this value in their immutable state metadata.
Fields§
§fluid_id: &'static FluidThe 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§
§impl FluidState
impl FluidState
pub const EMPTY: FluidState
pub const EMPTY: FluidState
The empty fluid state.
pub const fn new(fluid: &'static Fluid, amount: u8, falling: bool) -> FluidState
pub const fn new(fluid: &'static Fluid, amount: u8, falling: bool) -> FluidState
Creates a new fluid state.
pub const fn source(fluid: &'static Fluid) -> FluidState
pub const fn source(fluid: &'static Fluid) -> FluidState
Creates a source fluid state (amount=8, not falling).
pub const fn flowing(
fluid: &'static Fluid,
amount: u8,
falling: bool,
) -> FluidState
pub const fn flowing( fluid: &'static Fluid, amount: u8, falling: bool, ) -> FluidState
Creates a flowing fluid state.
pub const fn is_source(&self) -> bool
pub const fn is_source(&self) -> bool
Returns true if this state is owned by a source fluid type.
Vanilla FluidState.isSource() delegates to the owning fluid. Source
fluids can still carry FALLING=true through FlowingFluid.getSource.
pub const fn is_full(&self) -> bool
pub const fn is_full(&self) -> bool
Returns true if this fluid has vanilla’s full amount (8).
This intentionally does not require a source fluid type. Vanilla
FluidState.isFull() is getAmount() == 8, so a falling full fluid is
full without being a source.
pub const fn is_randomly_ticking(&self) -> bool
pub const fn is_randomly_ticking(&self) -> bool
Returns whether this fluid receives random ticks.
pub fn own_height(&self) -> f32
pub fn own_height(&self) -> f32
Returns the fluid’s own height (0.0 to ~0.89).
pub fn from_block_level(fluid: &'static Fluid, level: u8) -> FluidState
pub fn from_block_level(fluid: &'static Fluid, level: u8) -> FluidState
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)
pub 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).
pub fn create_legacy_block(self) -> BlockStateId
Trait Implementations§
§impl Clone for FluidState
impl Clone for FluidState
§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
§impl Debug for FluidState
impl Debug for FluidState
impl Eq for FluidState
§impl FluidStateExt for FluidState
impl FluidStateExt for FluidState
§impl PartialEq for FluidState
impl PartialEq for FluidState
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
§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.§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
self with key and returns true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>