Model

Struct Model 

Source
pub struct Model {
    pub parent: Option<String>,
    pub display: Option<Display>,
    pub textures: Option<Textures>,
    pub elements: Option<Vec<Element>>,
    pub ambient_occlusion: Option<bool>,
    pub gui_light_mode: Option<GuiLightMode>,
    pub overrides: Option<Vec<OverrideCase>>,
}
Expand description

A block or item model as stored in the assets/<namespace>/models/{block,item}/ directories.

See also the corresponding section of the wiki page

Fields§

§parent: Option<String>

Specifies that this model should inherit fields from the model at the given resource location. If both parent and elements are set, the elements field overrides the elements field from the parent model.

For an item model, this can be set to a couple builtin values:

  • "item/generated", to use a model that is created out of the item’s icon.

  • "builtin/entity", to load a model from an entity file.

    • As you cannot specify the entity, this does not work for all items (only for chests, ender chests, mob heads, shields, banners and tridents).
§display: Option<Display>

Contains the different places where item models are displayed in different views.

§textures: Option<Textures>

Contains the textures of the model.

§elements: Option<Vec<Element>>

Contains all the elements of the model.

If both parent and elements are set, the elements tag overrides the elements tag from the previous model.

§ambient_occlusion: Option<bool>

Whether to use ambient occlusion (true - default), or not (false).

Applies only to block models.

§gui_light_mode: Option<GuiLightMode>

Specifies how to shade the model in the GUI.

Can be front or side. If set to side, the model is rendered like a block. If set to front, model is shaded like a flat item. Defaults to side.

Applies only to item models.1


  1. In versions >= 1.16.2, it appears that block/block.json also has this field set. 

§overrides: Option<Vec<OverrideCase>>

Specifies cases in which a different model should be used based on item tags.

All cases are evaluated in order from top to bottom and last predicate that matches overrides. However, overrides are ignored if it has been already overridden once, for example this avoids recursion on overriding to the same model.

Applies only to item models.

Trait Implementations§

Source§

impl Clone for Model

Source§

fn clone(&self) -> Model

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Model

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Model

Source§

fn default() -> Model

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Model

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Model

Source§

fn eq(&self, other: &Model) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Model

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Model

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnwindSafe for Model

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,