pub struct BlockLootContext<'a> {
world: &'a Arc<World>,
pos: BlockPos,
entity: Option<&'a dyn Entity>,
tool: Option<&'a ItemStack>,
luck: f32,
}Expand description
Live parameters used to resolve a block’s loot.
This is the Steel counterpart to vanilla’s block LootParams. Behaviors can
override loot generation while retaining the original tool, entity, luck,
and position when delegating to another block state.
Fields§
§world: &'a Arc<World>§pos: BlockPos§entity: Option<&'a dyn Entity>§tool: Option<&'a ItemStack>§luck: f32Implementations§
Source§impl<'a> BlockLootContext<'a>
impl<'a> BlockLootContext<'a>
Sourcepub const fn new(world: &'a Arc<World>, pos: BlockPos) -> Self
pub const fn new(world: &'a Arc<World>, pos: BlockPos) -> Self
Creates a no-tool block loot context.
Sourcepub const fn with_entity(self, entity: Option<&'a dyn Entity>) -> Self
pub const fn with_entity(self, entity: Option<&'a dyn Entity>) -> Self
Adds the entity responsible for destroying the block.
Sourcepub const fn with_tool(self, tool: &'a ItemStack) -> Self
pub const fn with_tool(self, tool: &'a ItemStack) -> Self
Adds the tool used to destroy the block.
Sourcepub fn get_drops(&self, state: BlockStateId) -> Vec<ItemStack>
pub fn get_drops(&self, state: BlockStateId) -> Vec<ItemStack>
Resolves loot for another state with the same vanilla loot parameters.
pub(crate) const fn entity(&self) -> Option<&'a dyn Entity>
pub(crate) const fn tool(&self) -> Option<&'a ItemStack>
pub(crate) const fn luck(&self) -> f32
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for BlockLootContext<'a>
impl<'a> !UnwindSafe for BlockLootContext<'a>
impl<'a> Freeze for BlockLootContext<'a>
impl<'a> Send for BlockLootContext<'a>
impl<'a> Sync for BlockLootContext<'a>
impl<'a> Unpin for BlockLootContext<'a>
impl<'a> UnsafeUnpin for BlockLootContext<'a>
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<>>