Struct ModBlockEntityView
pub struct ModBlockEntityView<'a> { /* private fields */ }Expand description
A hook’s mutable block entity payload, with a read-only type identity. The private handle cannot be constructed or taken out by a mod.
use mod_api::{BlockEntityTickEvent, ModBlockEntity};
fn replace(event: &mut BlockEntityTickEvent<'_>) {
*event.entity = ModBlockEntity::default();
}use mod_api::BlockEntityTickEvent;
fn take(event: &mut BlockEntityTickEvent<'_>) {
let _ = std::mem::take(&mut event.entity);
}use mod_api::{BlockEntityTickEvent, ModBlockEntity};
fn access(event: &mut BlockEntityTickEvent<'_>) {
let _: &mut ModBlockEntity = event.entity.entity;
}Implementations§
§impl<'a> ModBlockEntityView<'a>
impl<'a> ModBlockEntityView<'a>
pub fn set_client_update_fields(&mut self, fields: BTreeMap<JavaString, Tag>)
pub fn set_client_update_fields(&mut self, fields: BTreeMap<JavaString, Tag>)
Replace the one-shot fields the block’s next change sends clients; an empty compound
clears them. They go over what block_entity_update_tag gives (or alone, without
one) in the single packet every current viewer gets, and are gone. Call
block_entity_sync to send them: until a change reaches a viewer they wait, however
many chunks are sent, and they end with the block entity. They are for a one-shot
effect, not state: nothing saves, clones or compares them, and the revision stays.
A client merges them into its copy’s nbt as any update field, where they stay until
sent again: a changing value, such as a counter, tells one effect from the next.
Fields that would take the packet past what a client reads (2 MiB of network NBT) are
dropped with a warning, and the change goes without them. A transaction that rolls the
block entity back also drops a batch queued before it.