pub trait CropLike {
// Required methods
fn block(&self) -> BlockRef;
fn age_property(&self) -> &IntProperty;
fn max_age(&self) -> u8;
fn clone_item_stack(&self) -> ItemStack;
// Provided methods
fn should_random_tick(&self) -> bool { ... }
fn get_age(&self, state: BlockStateId) -> u8 { ... }
fn get_state_for_age(&self, age: u8) -> BlockStateId { ... }
fn is_max_age(&self, state: BlockStateId) -> bool { ... }
fn has_sufficient_light(
&self,
world: &dyn LevelReader,
pos: BlockPos,
) -> bool { ... }
fn has_sufficient_growth_light(
&self,
world: &dyn LevelReader,
pos: BlockPos,
) -> bool { ... }
fn get_growth_speed(&self, world: &Arc<World>, pos: BlockPos) -> f32 { ... }
fn on_random_tick(
&self,
state: BlockStateId,
world: &Arc<World>,
pos: BlockPos,
) { ... }
}Required Methods§
fn block(&self) -> BlockRef
fn age_property(&self) -> &IntProperty
fn max_age(&self) -> u8
fn clone_item_stack(&self) -> ItemStack
Provided Methods§
Sourcefn should_random_tick(&self) -> bool
fn should_random_tick(&self) -> bool
Additional checks before calling the standard on_random_tick code
fn get_age(&self, state: BlockStateId) -> u8
fn get_state_for_age(&self, age: u8) -> BlockStateId
fn is_max_age(&self, state: BlockStateId) -> bool
fn has_sufficient_light(&self, world: &dyn LevelReader, pos: BlockPos) -> bool
fn has_sufficient_growth_light( &self, world: &dyn LevelReader, pos: BlockPos, ) -> bool
Sourcefn get_growth_speed(&self, world: &Arc<World>, pos: BlockPos) -> f32
fn get_growth_speed(&self, world: &Arc<World>, pos: BlockPos) -> f32
Calculates the growth speed based on surrounding farmland.
Factors affecting growth speed:
- Farmland below: +1.0 (dry) or +3.0 (hydrated)
- Adjacent farmland: +0.25 (dry) or +0.75 (hydrated)
- Same crop in row: /2.0 speed penalty
fn on_random_tick(&self, state: BlockStateId, world: &Arc<World>, pos: BlockPos)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".