Skip to main content

LootDrops

Struct LootDrops 

#[non_exhaustive]
pub struct LootDrops<'a> { pub table: &'a str, pub dimension: &'a str, pub origin: [f64; 3], pub block: Option<([i32; 3], BlockState)>, pub entity: Option<(u32, &'a str)>, pub player: Option<u128>, pub damage_source: Option<HurtSource<'a>>, pub tool: Option<&'a ItemStack>, pub explosion: Option<f32>, pub used: bool, }
Expand description

What dropped the items heard by the loot_drops hook.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§table: &'a str

The block’s or mob’s own loot table (minecraft:blocks/stone, minecraft:entities/zombie); empty when none rolled: the block or mob has none, the mob_drops rule is off, a baby animal. A mob’s drops may hold more: a charged creeper’s head, a fox’s mouth item.

§dimension: &'a str

The level they drop in (minecraft:overworld).

§origin: [f64; 3]

LootContextParams.ORIGIN: a broken block’s centre, a mob’s position.

§block: Option<([i32; 3], BlockState)>

The block broken: its position and state.

§entity: Option<(u32, &'a str)>

The mob that died, or the entity a player’s use dropped them from (the sheep sheared, the item frame broken): its entity ID and type (minecraft:zombie).

§player: Option<u128>

The player who broke the block or killed the mob, when known. A mob names one only while it remembers the player’s hit (100 ticks), so one that dies to lava long after names none.

§damage_source: Option<HurtSource<'a>>

LootContextParams.DAMAGE_SOURCE of this death invocation. None for non-death drops. Environmental deaths have a source but no causing entity. causing and direct are the attacking and direct attacking entity IDs; 0 means absent or unknown, as on the other damage hooks.

§tool: Option<&'a ItemStack>

The breaking or using tool (LootContextParams.TOOL). Always None for entity deaths. For the attacker’s live hand, resolve damage_source.causing through host.entity, then host.living, and read living.hand_item(host, Hand::Main). This reads when called, including changes made by earlier loot listeners.

§explosion: Option<f32>

The radius of the explosion that broke the block.

§used: bool

A player’s use dropped them rather than a break or a death: shears on a sheep, a mooshroom, a snow golem or a bogged, a brush on an armadillo or a suspicious block, shears carving a pumpkin, picking sweet berries or cave vines, a hit taking an item frame or its item, or untying a lead or cutting it with shears. player names them, or is None when a dispenser’s shears sheared a mooshroom; block or entity says what dropped them. A mob that a player killed while leashed drops its lead on its next tick as a call of its own (entity the mob, player its killer, table empty, used false).

Trait Implementations§

§

impl<'a> Clone for LootDrops<'a>

§

fn clone(&self) -> LootDrops<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'a> Copy for LootDrops<'a>

§

impl<'a> Debug for LootDrops<'a>

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<'a> From<LootDrops<'a>> for LootDrops<'a>

§

fn from(v: LootDrops<'a>) -> LootDrops<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for LootDrops<'a>

§

impl<'a> RefUnwindSafe for LootDrops<'a>

§

impl<'a> Send for LootDrops<'a>

§

impl<'a> Sync for LootDrops<'a>

§

impl<'a> Unpin for LootDrops<'a>

§

impl<'a> UnsafeUnpin for LootDrops<'a>

§

impl<'a> UnwindSafe for LootDrops<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.