pub struct WeatheringCopper {
weather_state: WeatherState,
}Expand description
Composable helper for copper weathering/oxidation logic.
Add this as a field to block implementations that should support weathering.
In YourBlock::random_tick call WeatheringCopper::change_over_time
Fields§
§weather_state: WeatherStateImplementations§
Source§impl WeatheringCopper
impl WeatheringCopper
Sourcepub const fn new(weather_state: WeatherState) -> Self
pub const fn new(weather_state: WeatherState) -> Self
Creates a new WeatheringCopper helper with the given oxidation stage.
Sourcepub fn change_over_time(
&self,
state: BlockStateId,
world: &Arc<World>,
pos: BlockPos,
)
pub fn change_over_time( &self, state: BlockStateId, world: &Arc<World>, pos: BlockPos, )
Advances the weathering state and replaces the block, with a 5.7% chance.
Vanilla: [ChangeOverTimeBlock.changeOverTime]
Sourcefn get_next_state(
&self,
state: BlockStateId,
world: &Arc<World>,
pos: BlockPos,
) -> Option<BlockStateId>
fn get_next_state( &self, state: BlockStateId, world: &Arc<World>, pos: BlockPos, ) -> Option<BlockStateId>
Checks the neighbors and calculates the next BlockStateId for the weathering copper.
- Scan Manhattan distance 4 for copper neighbors
- If any younger neighbor exists, abort
- Probability = ((older+1)/(older+same+1))² ×
chance_modifier - On success, advance to next oxidation stage preserving block properties
Vanilla: ChangeOverTimeBlock.getNextState
fn get_chance_modifier(&self) -> f32
Auto Trait Implementations§
impl Freeze for WeatheringCopper
impl RefUnwindSafe for WeatheringCopper
impl Send for WeatheringCopper
impl Sync for WeatheringCopper
impl Unpin for WeatheringCopper
impl UnsafeUnpin for WeatheringCopper
impl UnwindSafe for WeatheringCopper
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
Mutably borrows from an owned value. Read more
§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> ⓘ
Converts
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> ⓘ
Converts
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 moreWraps this value in an
Arc<SyncMutex<>>