pub struct StandingAndWallBlockItem {
pub standing_block: BlockRef,
pub wall_block: BlockRef,
pub attachment_direction: Direction,
}Expand description
Behavior for items that place either a standing or wall variant of a block.
Used for torches (torch/wall_torch), soul torches, copper torches, etc.
When placed looking down (toward attachmentDirection), places the standing variant.
When placed looking horizontally or up, places the wall variant.
The attachmentDirection is typically Direction::Down for torches, meaning:
- Looking down → place standing torch on top of block below
- Looking horizontally → place wall torch on side of block
Fields§
§standing_block: BlockRefThe block to place when looking toward attachmentDirection (e.g., torch).
wall_block: BlockRefThe block to place otherwise (e.g., wall_torch).
attachment_direction: DirectionThe direction that triggers the standing block placement.
For torches this is Direction::Down - when looking down, place standing torch.
Implementations§
Source§impl StandingAndWallBlockItem
impl StandingAndWallBlockItem
Sourcepub const fn new(
standing_block: BlockRef,
wall_block: BlockRef,
attachment_direction: Direction,
) -> Self
pub const fn new( standing_block: BlockRef, wall_block: BlockRef, attachment_direction: Direction, ) -> Self
Creates a new standing and wall block item behavior.
§Arguments
standing_block- Block placed when looking towardattachment_directionwall_block- Block placed when looking away fromattachment_directionattachment_direction- Direction that triggers standing block (e.g.,Downfor torches)
Sourcepub fn get_placement_state(
&self,
place_context: &BlockPlaceContext<'_>,
) -> Option<BlockStateId>
pub fn get_placement_state( &self, place_context: &BlockPlaceContext<'_>, ) -> Option<BlockStateId>
Determines which block variant to use based on placement context.
Vanilla caches the wall state once, then iterates through directions to decide
between standing and wall variants. This matches StandingAndWallBlockItem.getPlacementState.
Sourcepub fn get_block_for_state(&self, state: BlockStateId) -> BlockRef
pub fn get_block_for_state(&self, state: BlockStateId) -> BlockRef
Gets the block reference for a placed state (for sound lookup).
Trait Implementations§
Source§impl ItemBehavior for StandingAndWallBlockItem
impl ItemBehavior for StandingAndWallBlockItem
Source§fn use_on(&self, context: &mut UseOnContext<'_>) -> InteractionResult
fn use_on(&self, context: &mut UseOnContext<'_>) -> InteractionResult
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Source§fn get_name<'a>(&self, stack: &'a ItemStack) -> Cow<'a, TextComponent>
fn get_name<'a>(&self, stack: &'a ItemStack) -> Cow<'a, TextComponent>
Item.getName(stack).Source§fn use_item(&self, context: &mut UseItemContext<'_>) -> InteractionResult
fn use_item(&self, context: &mut UseItemContext<'_>) -> InteractionResult
Source§fn interact_living_entity(
&self,
_stack: &mut ItemStack,
_player: &Player,
_target: &dyn LivingEntity,
_hand: InteractionHand,
) -> InteractionResult
fn interact_living_entity( &self, _stack: &mut ItemStack, _player: &Player, _target: &dyn LivingEntity, _hand: InteractionHand, ) -> InteractionResult
ItemStack.interactLivingEntity.Source§fn get_item_damage_source(
&self,
_attacker: &dyn LivingEntity,
) -> Option<DamageSource>
fn get_item_damage_source( &self, _attacker: &dyn LivingEntity, ) -> Option<DamageSource>
Item.getItemDamageSource.Source§fn get_attack_damage_bonus(
&self,
_attacker: &dyn LivingEntity,
_victim: &dyn Entity,
_base_damage: f32,
_damage_source: &DamageSource,
) -> f32
fn get_attack_damage_bonus( &self, _attacker: &dyn LivingEntity, _victim: &dyn Entity, _base_damage: f32, _damage_source: &DamageSource, ) -> f32
Item.getAttackDamageBonus.Source§fn hurt_enemy(
&self,
_stack: &mut ItemStack,
_target: &dyn LivingEntity,
_attacker: &dyn LivingEntity,
)
fn hurt_enemy( &self, _stack: &mut ItemStack, _target: &dyn LivingEntity, _attacker: &dyn LivingEntity, )
Item.hurtEnemy.Source§fn post_hurt_enemy(
&self,
_stack: &mut ItemStack,
_target: &dyn LivingEntity,
_attacker: &dyn LivingEntity,
)
fn post_hurt_enemy( &self, _stack: &mut ItemStack, _target: &dyn LivingEntity, _attacker: &dyn LivingEntity, )
Item.postHurtEnemy.Auto Trait Implementations§
impl !RefUnwindSafe for StandingAndWallBlockItem
impl !UnwindSafe for StandingAndWallBlockItem
impl Freeze for StandingAndWallBlockItem
impl Send for StandingAndWallBlockItem
impl Sync for StandingAndWallBlockItem
impl Unpin for StandingAndWallBlockItem
impl UnsafeUnpin for StandingAndWallBlockItem
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
§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<>>