Skip to main content

Module behavior

Module behavior 

Source
Expand description

Block and item behavior system.

This module contains the behavior traits and registries that define how blocks and items behave dynamically. This is separate from the static data in steel-registry to maintain a clean separation between constant data and functional/dynamic behavior.

§Architecture

After the main registry (steel-registry) is frozen, behavior registries are created:

  • BlockBehaviorRegistry - assigns default or custom behaviors to each block
  • ItemBehaviorRegistry - assigns default or custom behaviors to each item

§Usage

use steel_core::behavior::{init_behaviors, BLOCK_BEHAVIORS, ITEM_BEHAVIORS};

// After registry is frozen, call once at startup:
init_behaviors();

// Then access behaviors via the global registries:
let behavior = BLOCK_BEHAVIORS.get_behavior(block);

Re-exports§

pub use fluid::FLUID_BEHAVIORS;
pub use fluid::FluidBehaviorRegistry;
pub use items::BlockItem;
pub use items::BucketItem;
pub use items::DefaultItemBehavior;
pub use items::DoubleHighBlockItem;
pub use items::EnderEyeItem;
pub use items::HangingSignItem;
pub use items::ShovelItem;
pub use items::SignItem;
pub use items::StandingAndWallBlockItem;

Modules§

block 🔒
Block behavior trait and registry.
block_behaviors
Generated block behavior assignments.
blocks
Block behavior implementations for vanilla blocks.
candle_cakes
context 🔒
Context types and results for block and item interactions.
fluid
Fluid behavior registry.
item 🔒
Item behavior trait and registry.
item_behaviors
Generated item behavior assignments.
item_utils 🔒
Helpers shared by item behavior implementations.
items
Item behavior implementations.
strippables
Generated Mapping of Logs and Woods to their stripped Variant
waxables
Generated mapping of copper blocks to their waxed variants.
weathering

Structs§

BlockBehaviorLock
Wrapper for the global block behavior registry that implements Deref.
BlockBehaviorRegistry
Registry for block behaviors.
BlockCollisionContext
Entity facts used by vanilla CollisionContext for block collision shapes.
BlockHitResult
Result of a ray cast hitting a block.
BlockLootContext
Live parameters used to resolve a block’s loot.
BlockPlaceContext
Context for placing a block.
DefaultBlockBehavior
Default placement plus the common water tick used by unported waterlogged blocks.
EntityFallDamage
Fall damage requested by a block landing hook.
EntityFallOnContext
Entity facts needed by Block.fallOn.
EntityFallOnFacts
Entity facts needed by Block.fallOn.
EntityLandingContext
Entity facts needed by Block.updateEntityMovementAfterFallOn.
InventoryAccess
Access to the player’s inventory.
ItemBehaviorLock
Wrapper for the global item behavior registry that implements Deref.
ItemBehaviorRegistry
Registry for item behaviors.
PlacementSource
Player and item data retained across one block placement operation.
UseItemContext
Context for using an item (general usage).
UseOnContext
Context for using an item on a block.

Enums§

BlockEntityCreation
Result of invoking a block’s Vanilla block-entity factory.
InteractionResult
Result of an interaction (item use, block use, etc.)
PlacementOrientation
Placement direction behavior derived from either a player or a synthetic caller.

Statics§

BLOCK_BEHAVIORS
Global block behavior registry.
ITEM_BEHAVIORS
Global item behavior registry.

Traits§

BlockBehavior
Trait defining the behavior of a block.
BlockStateBehaviorExt
Extension trait for BlockStateId that provides access to behavior-dependent methods.
ItemBehavior
Trait defining the behavior of an item.
RailBehavior
Shared behavior exposed by blocks in vanilla’s BaseRailBlock hierarchy.

Functions§

init_behaviors
Initializes the global behavior registries.

Type Aliases§

BlockCollisionBoxes
Resolved block-local collision boxes for a live block state.