Skip to main content

EnchantmentKind

Struct EnchantmentKind 

Source
pub struct EnchantmentKind {
Show 15 fields enchant_slots: Shared<SimpleContainer>, block_pos: BlockPos, world: Arc<World>, item: Section, lapis: Section, player_slots: PlayerInventorySections, enchantment_seed: i32, table_changes_seen: u32, costs: [i32; 3], enchant_clue: [Option<i32>; 3], level_clue: [Option<i32>; 3], cost_slots: [DataSlot; 3], seed_slot: DataSlot, enchant_clue_slots: [DataSlot; 3], level_clue_slots: [DataSlot; 3],
}
Expand description

Per-menu enchanting table state: the two table slots, the seeded offers, and their client mirrors.

Fields§

§enchant_slots: Shared<SimpleContainer>

The table’s own two slots, indexed by ITEM_SLOT and LAPIS_SLOT.

§block_pos: BlockPos§world: Arc<World>§item: Section§lapis: Section§player_slots: PlayerInventorySections§enchantment_seed: i32§table_changes_seen: u32

enchant_slots.times_changed() when the offers were last computed.

§costs: [i32; 3]§enchant_clue: [Option<i32>; 3]

Registry id of the shown enchantment per offer

§level_clue: [Option<i32>; 3]

Level of the shown enchantment per offer

§cost_slots: [DataSlot; 3]§seed_slot: DataSlot§enchant_clue_slots: [DataSlot; 3]§level_clue_slots: [DataSlot; 3]

Implementations§

Source§

impl EnchantmentKind

Source

const fn client_value(value: i32) -> i16

Data slots travel as protocol shorts; vanilla sends the low 16 bits of each int.

Source

fn seeded_random(seed: i32) -> LegacyRandom

Source

fn sync_data(&self, behavior: &mut MenuBehavior)

Source

const fn clear_offers(&mut self)

Source

fn count_bookshelves(&self) -> i32

Source

fn enchantment_list( &self, random: &mut LegacyRandom, stack: &ItemStack, slot: usize, enchantment_cost: i32, ) -> Vec<EnchantmentInstance>

Selects an offer using seed + slot; books discard one result if several are rolled.

Source

fn table_changes(&self, guard: &ContainerLockGuard) -> Option<u32>

enchant_slots.times_changed() as seen through guard.

Source

fn update_offers( &mut self, behavior: &mut MenuBehavior, guard: &mut ContainerLockGuard, )

Rerolls the three offers for the table item

Trait Implementations§

Source§

impl DowncastType for EnchantmentKind

Source§

const TYPE_KEY: DowncastTypeKey

The process-wide key for this concrete type.
Source§

impl MenuKind for EnchantmentKind

Source§

fn slots_changed( &mut self, behavior: &mut MenuBehavior, guard: &mut ContainerLockGuard, _player: &Player, )

Rerolls offers only when the table slots change, ignoring player-inventory clicks.

Source§

fn click_menu_button( &mut self, behavior: &mut MenuBehavior, button_id: i32, player: &Player, ) -> bool

Applies the selected offer when the player can pay.

Source§

fn quick_move( &mut self, behavior: &mut MenuBehavior, guard: &mut ContainerLockGuard, slot_index: usize, player: &Player, ) -> Option<ItemStack>

Moves table items back to inventory, lapis to its slot, and one other item into the empty item slot.

Source§

fn still_valid(&self, _behavior: &MenuBehavior, player: &Player) -> bool

Returns true if this menu is still valid for the player.
Source§

fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)

Extra cleanup on close beyond [Menu::removed].
Source§

fn on_rename( &mut self, _behavior: &mut MenuBehavior, _name: String, _player: &Player, )

Applies a rename from the client (anvil-style text input) and recomputes any result. No-op for kinds without a rename input.
Source§

fn on_open( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )

Runs after initial contents are built but before they’re sent, so anything populated here appears in the first render.
Source§

fn on_tick( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )

Runs once per tick per viewer while open, before changes are synced.
Source§

fn on_slot_clicked( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _click: Click, _player: &Player, ) -> ClickOutcome

Runs for every non-drag click before default handling. Return ClickOutcome::Consume to treat the slot as a button, or ClickOutcome::Fallthrough for default handling.
Source§

fn on_drag( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _action: QuickCraft, _player: &Player, ) -> ClickOutcome

Runs for each drag phase before default handling. Return ClickOutcome::Consume to cancel the drag.
Source§

fn can_drag_to(&self, _slot_index: usize) -> bool

Returns true if a drag may distribute items into slot_index.
Source§

fn can_take_item_for_pick_all( &self, _carried: &ItemStack, _slot_index: usize, ) -> bool

Returns true if an item may be taken from slot_index during pickup-all.
Source§

fn on_update_effects( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _primary: Option<MobEffectRef>, _secondary: Option<MobEffectRef>, ) -> bool

Handles a beacon effect update from the client’s set-beacon packet. Returns false when the selection or payment is invalid.

Auto Trait Implementations§

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> Downcast for T
where T: ErasedType + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: DowncastType,

Returns whether the erased value has concrete type T.
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: DowncastType,

Returns the erased value as T when its key matches.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: DowncastType,

Returns the erased value as mutable T when its key matches.
Source§

impl<T> ErasedType for T
where T: DowncastType,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>> ⓘ

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more