Trait ClientRenderClientHost
pub trait ClientRenderClientHost {
// Provided methods
fn instance_group_write(
&self,
group: InstanceGroupRef,
first: u32,
instances: &[ModelInstance],
) -> Result<(), GroupError> { ... }
fn instance_group_set_len(
&self,
group: InstanceGroupRef,
len: u32,
) -> Result<(), GroupError> { ... }
fn instance_group_set_transform(
&self,
group: InstanceGroupRef,
transform: [f32; 12],
) -> Result<(), GroupError> { ... }
fn instance_group_destroy(
&self,
group: InstanceGroupRef,
) -> Result<(), GroupError> { ... }
fn refresh_render_visibility(&mut self) { ... }
fn refresh_biome_colors(&mut self) { ... }
fn mod_image(&mut self, width: u32, height: u32, rgba: &[u8]) -> bool { ... }
fn block_face_sprite(
&self,
state: BlockState,
side: Direction,
) -> Option<BlockFaceTexture> { ... }
fn block_sprites(&self, blocks: &[BlockState]) -> Vec<Option<BlockSprites>> { ... }
fn texture_sprites(&self, textures: &[&str]) -> Vec<Option<SpriteRef>> { ... }
fn gui_sprite(&self, sprite: &Identifier) -> Option<AtlasRegion> { ... }
fn block_sprites_version(&self) -> u64 { ... }
}Expand description
The client host’s methods of the client_render area, implemented by the game and reached through crate::ClientHost.
Provided Methods§
fn instance_group_write(
&self,
group: InstanceGroupRef,
first: u32,
instances: &[ModelInstance],
) -> Result<(), GroupError>
fn instance_group_write( &self, group: InstanceGroupRef, first: u32, instances: &[ModelInstance], ) -> Result<(), GroupError>
Atomically overwrite retained model copies; use InstanceGroupRef::write.
fn instance_group_set_len(
&self,
group: InstanceGroupRef,
len: u32,
) -> Result<(), GroupError>
fn instance_group_set_len( &self, group: InstanceGroupRef, len: u32, ) -> Result<(), GroupError>
Set the drawn length; use InstanceGroupRef::set_len.
fn instance_group_set_transform(
&self,
group: InstanceGroupRef,
transform: [f32; 12],
) -> Result<(), GroupError>
fn instance_group_set_transform( &self, group: InstanceGroupRef, transform: [f32; 12], ) -> Result<(), GroupError>
Replace the group pose; use InstanceGroupRef::set_group_transform.
fn instance_group_destroy(
&self,
group: InstanceGroupRef,
) -> Result<(), GroupError>
fn instance_group_destroy( &self, group: InstanceGroupRef, ) -> Result<(), GroupError>
Retire retained model copies; use InstanceGroupRef::destroy.
fn refresh_render_visibility(&mut self)
fn refresh_render_visibility(&mut self)
Side: client.
Asks native_block_render_visibility again for every state and, when the answers differ
from those in use, remeshes every loaded section with them. Call it when your answer changes (a toggle key, a scan
finishing) and once when the player joins, not every frame: a rebuild takes the workers a
few seconds. With no part answering, nothing is asked and the mesher keeps its no-mod path.
fn refresh_biome_colors(&mut self)
fn refresh_biome_colors(&mut self)
Side: client.
Asks native_biome_colors again for every biome and, when the colours
differ from those in use, rebuilds every loaded section and the far
terrain with them (LevelRenderer.allChanged, as changing Biome Blend
does). Call it when your colours change (a new season, a new day of a
slow fade) and once when the player joins, not every frame: a rebuild
takes the workers a few seconds.
fn mod_image(&mut self, width: u32, height: u32, rgba: &[u8]) -> bool
fn mod_image(&mut self, width: u32, height: u32, rgba: &[u8]) -> bool
Side: client.
A mod’s own RGBA image, uploaded into the HUD atlas slot
MOD_IMAGE_SPRITE and drawn with
native_sprite: its own source rectangle crops and stretches it. rgba
is width * height pixels of four bytes, each side at most
MOD_IMAGE_SIZE; false when it is not that
size. The upload costs a texture patch of the image, so send one when the
image changed, not every frame.
fn block_face_sprite(
&self,
state: BlockState,
side: Direction,
) -> Option<BlockFaceTexture>
fn block_face_sprite( &self, state: BlockState, side: Direction, ) -> Option<BlockFaceTexture>
Side: client.
Published asset/data read: available in Setup, Reloading and World.
For a client mod drawing a block entity: the texture block state state’s model shows on its side
(block/oak_planks: vanilla’s without their namespace, a mod’s with it), by the name native_draw_cube and
native_draw_quad take, and that face’s
tint index (-1 for none): a copycat block drawing a box of its material’s textures with native_draw_cube,
kept with BlockEntityDraw::keep. The face culled against that side comes first, else the first facing it;
None when the model has no face that way or isn’t baked. API @API:block_face_sprite@.
fn block_sprites(&self, blocks: &[BlockState]) -> Vec<Option<BlockSprites>>
fn block_sprites(&self, blocks: &[BlockState]) -> Vec<Option<BlockSprites>>
Side: client.
Published asset/data read: available in Setup, Reloading and World.
For a client mod: what each resolved block state draws on its six sides, preserving
its properties without reparsing names. Resolve states once at load. Each face’s sprite (array and
layer, as WorldDrawn::block_sprites cuts them), where it lies on the side, how its texture runs across it,
its tint source and whether it is cut out, translucent or animated; its particle sprite; whether it is a plain
cube. None for a block the game does not know. The model is the state’s first random variant. API
380.
fn texture_sprites(&self, textures: &[&str]) -> Vec<Option<SpriteRef>>
fn texture_sprites(&self, textures: &[&str]) -> Vec<Option<SpriteRef>>
Side: client.
Published asset/data read: available in Setup, Reloading and World.
For a client mod: each texture’s sprite by name (minecraft:block/stone, block/stone), none for one no
model uses. API 380.
fn gui_sprite(&self, sprite: &Identifier) -> Option<AtlasRegion>
fn gui_sprite(&self, sprite: &Identifier) -> Option<AtlasRegion>
Side: client.
Published asset/data read: available in Setup, Reloading and World.
For a client mod: where GUI sprite sprite lies in the GUI atlas and its size, none for one the atlas lacks
(a server’s metrics-only atlas lacks them all). The atlas names vanilla’s sprites by path alone
(gui/sprites/container/slot) and a mod’s with its namespace (mymod:gui/panel).
fn block_sprites_version(&self) -> u64
fn block_sprites_version(&self) -> u64
Side: client.
Published asset/data read: available in Setup, Reloading and World.
For a client mod: changes each time the resources load (a resource pack turned on or off can move every
sprite): ask native_block_sprites again then. API 380.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".