Skip to main content

ModBlockEntityView

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>

pub fn id(&self) -> &str

Id.

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.

Trait Implementations§

§

impl Deref for ModBlockEntityView<'_>

§

type Target = ModBlockEntityFields

The resulting type after dereferencing.
§

fn deref(&self) -> &<ModBlockEntityView<'_> as Deref>::Target

Dereferences the value.
§

impl DerefMut for ModBlockEntityView<'_>

§

fn deref_mut(&mut self) -> &mut <ModBlockEntityView<'_> as Deref>::Target

Mutably dereferences the value.
§

impl Put for ModBlockEntityView<'_>

§

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

Writes it.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.