Skip to main content

ThrowableItemProjectile

Trait ThrowableItemProjectile 

Source
pub trait ThrowableItemProjectile: ThrowableProjectile {
    // Required methods
    fn get_default_item(&self) -> ItemRef;
    fn set_item(&self, item: ItemStack);
    fn get_item(&self) -> ItemStack;

    // Provided methods
    fn set_item_clamped(&self, item: ItemStack) { ... }
    fn save_throwable_item(&self, nbt: &mut NbtCompound) { ... }
    fn load_throwable_item(&self, nbt: BorrowedNbtCompoundView<'_, '_>) { ... }
}
Expand description

Vanilla-shaped behavior shared by entities that extend ThrowableItemProjectile.

Required Methods§

Source

fn get_default_item(&self) -> ItemRef

Returns the item stack used when no persisted item can be loaded (e.g. a plain ender pearl, snowball, or egg).

Source

fn set_item(&self, item: ItemStack)

Sets the rendered item stack (vanilla setItem, count clamped to 1).

The concrete entity stores this in its synced data layer.

Source

fn get_item(&self) -> ItemStack

Returns the rendered item stack (vanilla getItem).

Provided Methods§

Source

fn set_item_clamped(&self, item: ItemStack)

Sets the rendered item stack, clamping its count to 1.

Source

fn save_throwable_item(&self, nbt: &mut NbtCompound)

Saves the item stack to NBT, omitting the tag entirely when the stack is empty.

Source

fn load_throwable_item(&self, nbt: BorrowedNbtCompoundView<'_, '_>)

Loads the item stack, falling back to the default item (vanilla readAdditionalSaveData).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§