Trait BlockStatesHost
pub trait BlockStatesHost {
// Provided methods
fn lit_block_name(&self, pos: [i32; 3]) -> Option<BlockKey> { ... }
fn fluid_key(&self, id: &str) -> Option<FluidKey> { ... }
fn block_state_id(&self, name: &str) -> Option<BlockState> { ... }
fn block_state_string(&self, state: BlockState) -> Option<String> { ... }
fn block_state_default(&self, block: BlockKey) -> Option<BlockState> { ... }
fn item_crafting_remainder(&self, stack: &ItemStack) -> Option<ItemStack> { ... }
fn block_item(&self, block: BlockKey) -> Option<ItemKey> { ... }
fn item_block(&self, item: ItemKey) -> Option<BlockKey> { ... }
}Expand description
The host’s methods both sides share of the block_states area, implemented by the game and reached through Host.
Provided Methods§
fn lit_block_name(&self, pos: [i32; 3]) -> Option<BlockKey>
fn lit_block_name(&self, pos: [i32; 3]) -> Option<BlockKey>
Side: both. Read a loaded, light-emitting block. No implicit chunk loading.
fn block_state_id(&self, name: &str) -> Option<BlockState>
fn block_state_id(&self, name: &str) -> Option<BlockState>
Side: both.
The state name names, read as /setblock reads a block
(BlockStateParser.parseForBlock): minecraft:oak_stairs[facing=east],
stone for minecraft:stone, the properties left out at their
default. Returns an owned block key and canonical local ordinal, never
vanilla’s numeric Block.getId. None for an unknown block,
a property it doesn’t have or a value it can’t take, or block NBT
({...}); and, as /setblock’s argument, for anything after the
block.
fn block_state_string(&self, state: BlockState) -> Option<String>
fn block_state_string(&self, state: BlockState) -> Option<String>
Side: both.
The state state as /setblock takes it back
(BlockStateParser.serialize): its block, then each property in
name order, minecraft:oak_stairs[facing=east,half=bottom,...], or
the block alone for one with no properties. None for an unknown key
or local ordinal; an invalid value never falls back to air.
fn block_state_default(&self, block: BlockKey) -> Option<BlockState>
fn block_state_default(&self, block: BlockKey) -> Option<BlockState>
Side: both.
The default state of the resolved block key:
Block.defaultBlockState, the one a block takes when nothing else
says. None for an unknown block.
fn item_crafting_remainder(&self, stack: &ItemStack) -> Option<ItemStack>
fn item_crafting_remainder(&self, stack: &ItemStack) -> Option<ItemStack>
Side: both.
Item.getCraftingRemainder: Horizon currently stores the remainder’s
item id, so the result is a single plain stack.
fn block_item(&self, block: BlockKey) -> Option<ItemKey>
fn block_item(&self, block: BlockKey) -> Option<ItemKey>
Side: both.
Block.asItem: the block’s item identity, including air for a block with
no item; None if either resolved identity is unavailable.
fn item_block(&self, item: ItemKey) -> Option<BlockKey>
fn item_block(&self, item: ItemKey) -> Option<BlockKey>
Side: both.
The block item places (BlockItem.getBlock, as Block.byItem reads
it): minecraft:wheat_seeds places minecraft:wheat, and a
standing/wall item places its standing block, not the wall variant.
None for an item that places no block, and for an unknown item.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".