Skip to main content

BlockTintSource

Trait BlockTintSource 

pub trait BlockTintSource:
    Send
    + Sync
    + 'static {
    // Required method
    fn color(&self, state: &BlockState, metadata: &dyn BlockMetadata) -> u32;

    // Provided methods
    fn color_in_world(
        &self,
        state: &BlockState,
        metadata: &dyn BlockMetadata,
        level: &dyn BlockAndTintGetter,
        pos: [i32; 3],
    ) -> u32 { ... }
    fn color_as_terrain_particle(
        &self,
        state: &BlockState,
        metadata: &dyn BlockMetadata,
        level: &dyn BlockAndTintGetter,
        pos: [i32; 3],
    ) -> u32 { ... }
    fn relevant_properties(&self) -> Vec<String> { ... }
}
Expand description

A mod’s block tint source: vanilla’s BlockTintSource. Colours are ARGB, and a face it colours is multiplied by their RGB, as vanilla’s block renderer does. Implemented once, held by the game, asked on the meshing workers, so it keeps no mutable state.

Required Methods§

fn color(&self, state: &BlockState, metadata: &dyn BlockMetadata) -> u32

color(state): the colour without a world, where the block is drawn away from a level (a block in a minecart, a mod’s drawn block). Also the default of the two below.

Provided Methods§

fn color_in_world( &self, state: &BlockState, metadata: &dyn BlockMetadata, level: &dyn BlockAndTintGetter, pos: [i32; 3], ) -> u32

colorInWorld(state, level, pos): the colour of the block at pos, as the chunk mesher draws it. The mesher asks once per block and tint index each time it meshes the section.

fn color_as_terrain_particle( &self, state: &BlockState, metadata: &dyn BlockMetadata, level: &dyn BlockAndTintGetter, pos: [i32; 3], ) -> u32

colorAsTerrainParticle(state, level, pos): the colour of the bits the block breaks into and of falling dust.

fn relevant_properties(&self) -> Vec<String>

relevantProperties(): the property names the colour depends on. Vanilla groups states for shared baked models by them (ModelGroupCollector); Horizon bakes every state, so the game does not read it.

Trait Implementations§

§

impl Wire for Box<dyn BlockTintSource>

§

const MIN: usize = 8

Minimum encoded size, used to reject impossible collection lengths.
§

fn put(&self, out: &mut Writer)

Encodes this value, recording failures on the writer.
§

fn put_owned(self, out: &mut Writer)

Consumes owned data when a resource’s ownership must cross the boundary.
§

fn take(input: &mut Reader<'_>) -> Result<Box<dyn BlockTintSource>, WireError>

Decodes one value, leaving any following bytes for the caller.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§