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: u32enchant_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
impl EnchantmentKind
Sourceconst fn client_value(value: i32) -> i16
const fn client_value(value: i32) -> i16
Data slots travel as protocol shorts; vanilla sends the low 16 bits of each int.
fn seeded_random(seed: i32) -> LegacyRandom
fn sync_data(&self, behavior: &mut MenuBehavior)
const fn clear_offers(&mut self)
fn count_bookshelves(&self) -> i32
Sourcefn enchantment_list(
&self,
random: &mut LegacyRandom,
stack: &ItemStack,
slot: usize,
enchantment_cost: i32,
) -> Vec<EnchantmentInstance>
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.
Sourcefn table_changes(&self, guard: &ContainerLockGuard) -> Option<u32>
fn table_changes(&self, guard: &ContainerLockGuard) -> Option<u32>
enchant_slots.times_changed() as seen through guard.
Sourcefn update_offers(
&mut self,
behavior: &mut MenuBehavior,
guard: &mut ContainerLockGuard,
)
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
impl DowncastType for EnchantmentKind
Source§const TYPE_KEY: DowncastTypeKey
const TYPE_KEY: DowncastTypeKey
Source§impl MenuKind for EnchantmentKind
impl MenuKind for EnchantmentKind
Source§fn slots_changed(
&mut self,
behavior: &mut MenuBehavior,
guard: &mut ContainerLockGuard,
_player: &Player,
)
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.
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>
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
fn still_valid(&self, _behavior: &MenuBehavior, player: &Player) -> bool
Source§fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)
fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)
Menu::removed].Source§fn on_rename(
&mut self,
_behavior: &mut MenuBehavior,
_name: String,
_player: &Player,
)
fn on_rename( &mut self, _behavior: &mut MenuBehavior, _name: String, _player: &Player, )
Source§fn on_open(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_player: &Player,
)
fn on_open( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )
Source§fn on_tick(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_player: &Player,
)
fn on_tick( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _player: &Player, )
Source§fn on_slot_clicked(
&mut self,
_behavior: &mut MenuBehavior,
_guard: &mut ContainerLockGuard,
_click: Click,
_player: &Player,
) -> ClickOutcome
fn on_slot_clicked( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _click: Click, _player: &Player, ) -> ClickOutcome
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
fn on_drag( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _action: QuickCraft, _player: &Player, ) -> ClickOutcome
ClickOutcome::Consume to cancel the drag.Source§fn can_drag_to(&self, _slot_index: usize) -> bool
fn can_drag_to(&self, _slot_index: usize) -> bool
slot_index.Source§fn can_take_item_for_pick_all(
&self,
_carried: &ItemStack,
_slot_index: usize,
) -> bool
fn can_take_item_for_pick_all( &self, _carried: &ItemStack, _slot_index: usize, ) -> bool
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
fn on_update_effects( &mut self, _behavior: &mut MenuBehavior, _guard: &mut ContainerLockGuard, _primary: Option<MobEffectRef>, _secondary: Option<MobEffectRef>, ) -> bool
false when the selection or payment is invalid.Auto Trait Implementations§
impl !RefUnwindSafe for EnchantmentKind
impl !UnwindSafe for EnchantmentKind
impl Freeze for EnchantmentKind
impl Send for EnchantmentKind
impl Sync for EnchantmentKind
impl Unpin for EnchantmentKind
impl UnsafeUnpin for EnchantmentKind
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
Source§impl<T> Downcast for Twhere
T: ErasedType + ?Sized,
impl<T> Downcast for Twhere
T: ErasedType + ?Sized,
Source§fn is<T>(&self) -> boolwhere
T: DowncastType,
fn is<T>(&self) -> boolwhere
T: DowncastType,
T.Source§fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastType,
fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastType,
T when its key matches.Source§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: DowncastType,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: DowncastType,
T when its key matches.Source§impl<T> ErasedType for Twhere
T: DowncastType,
impl<T> ErasedType for Twhere
T: DowncastType,
fn downcast_type_key(&self) -> DowncastTypeKey
fn downcast_data(&self) -> *const ()
fn downcast_data_mut(&mut self) -> *mut ()
§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> ⓘ
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> ⓘ
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 moreArc<SyncMutex<>>