pub struct AnvilKind {
input_container: Shared<SimpleContainer>,
result_container: Shared<ResultContainer>,
block_pos: BlockPos,
world: Arc<World>,
repair_item_count: Arc<AtomicI32>,
level_cost: DataSlot,
level_cost_value: Arc<AtomicI32>,
only_renaming: Arc<AtomicBool>,
item_name: SyncMutex<Option<String>>,
}Expand description
Per-menu anvil state: inputs, result, level cost, and rename text.
Fields§
§input_container: Shared<SimpleContainer>Input container (two slots).
result_container: Shared<ResultContainer>Result container (single virtual slot).
block_pos: BlockPos§world: Arc<World>§repair_item_count: Arc<AtomicI32>§level_cost: DataSlotClient-facing level cost data slot.
level_cost_value: Arc<AtomicI32>Level cost shared with AnvilResultHandler, kept in sync with level_cost.
only_renaming: Arc<AtomicBool>Whether the current result changes only the first input’s name.
item_name: SyncMutex<Option<String>>Implementations§
Source§impl AnvilKind
impl AnvilKind
Sourcefn set_cost(&mut self, behavior: &mut MenuBehavior, cost: i32)
fn set_cost(&mut self, behavior: &mut MenuBehavior, cost: i32)
Sets the level cost. The client receives the packet’s low 16 bits while the result handler retains the full server-side cost.
const fn client_cost(cost: i32) -> i16
Sourcepub(crate) fn create_result(
&mut self,
behavior: &mut MenuBehavior,
guard: &mut ContainerLockGuard,
player: &Player,
)
pub(crate) fn create_result( &mut self, behavior: &mut MenuBehavior, guard: &mut ContainerLockGuard, player: &Player, )
Builds the anvil result from combining and renaming the two inputs.
§Panics
Panics if the input container is not exactly two slots.
fn validate_item_name(name: String) -> Option<String>
fn can_store_enchantments(item_stack: &ItemStack) -> bool
Sourcepub const fn calculate_increased_repair_cost(old_repair_cost: i32) -> i32
pub const fn calculate_increased_repair_cost(old_repair_cost: i32) -> i32
Calculates repair cost
Trait Implementations§
Source§impl DowncastType for AnvilKind
impl DowncastType for AnvilKind
Source§const TYPE_KEY: DowncastTypeKey
const TYPE_KEY: DowncastTypeKey
Source§impl MenuKind for AnvilKind
impl MenuKind for AnvilKind
Source§fn still_valid(&self, _behavior: &MenuBehavior, player: &Player) -> bool
fn still_valid(&self, _behavior: &MenuBehavior, player: &Player) -> bool
Returns true while the original anvil remains in range.
Source§fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)
fn removed(&mut self, _behavior: &mut MenuBehavior, _player: &Player)
Clears the virtual result on close. Inputs are drained by 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, )
Sets the rename text and recomputes the result with it applied.
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, )
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.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>
Some to fully handle the quick-move, or
None to fall back to the route table.Auto Trait Implementations§
impl !Freeze for AnvilKind
impl !RefUnwindSafe for AnvilKind
impl !UnwindSafe for AnvilKind
impl Send for AnvilKind
impl Sync for AnvilKind
impl Unpin for AnvilKind
impl UnsafeUnpin for AnvilKind
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<>>