Struct minecraft_assets::api::ModelIdentifier[][src]

pub struct ModelIdentifier;
Expand description

Helper methods for dealing with model identifiers.

Why does this exist?

Prior to 1.13, model identifiers found in assets/<namespace>/blockstates/*.json did not include a prefix like block/ or item/ to disambiguate between different types of models.

Because of this, the minecraft-assets API forces the user to always specify which type of model they are trying to reference (note the existence of both BlockModel and ItemModel variants in ResourceKind). This way, the API will work with versions prior to 1.13.

So this struct is meant to wrap an identifier and extract its model name. See the model_name() documentation for more information.

Implementations

Returns the name of the model, stripping the leading path component if there is one.

Example
assert_eq!(ModelIdentifier::model_name("stone"), "stone");
assert_eq!(ModelIdentifier::model_name("block/oak_planks"), "oak_planks");
assert_eq!(ModelIdentifier::model_name("item/diamond_hoe"), "diamond_hoe");

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.