Changes

2,337 bytes added ,  19:23, 24 October 2020
Inital Import dokuwiki
The model system is Minecraft’s way of giving blocks and items their shapes. Through the model system, blocks and items are mapped to their models, which define how they look. One of the main goals of the model system is to allow not only textures but the entire shape of a block/item to be changed by resource packs. Indeed, any mod that adds items or blocks also contains a mini-resource pack for their blocks and items.

In order to link code to models and textures on disk, there exists the class <code>ResourceLocation</code>. One may recognize them from the registry system; however, their original purpose was to identify files on disk; they just happened to be useful as unique identifiers as well. A <code>ResourceLocation</code> is a simple object composed of two <code>String</code>s: a namespace and a path. When a <code>ResourceLocation</code> is represented as a plain string, it looks like <code><nowiki>namespace:path</nowiki></code>. When a <code>ResourceLocation</code> is created and a namespace isn’t explicitly given, the namespace defaults to <code>minecraft</code>.

{{Colored box|title=Info|content=It is good practice to include the namespace in all contexts.}}

The namespace of a <code>ResourceLocation</code> in the model system represents a directory directly underneath <code><nowiki>assets/</nowiki></code>. Usually, the namespace is the same as the modid (e.g. in vanilla Minecraft the namespace is always <code>minecraft</code>). The path portion of a <code>ResourceLocation</code> represents a context-sensitive path to file underneath the namespace. What the path means and where exactly it points depends on what’s using it. For example, when referring to a model, the path is normally resolved under <code>models</code>, but when referring to a texture it’s under <code>textures</code>. Therefore, <code><nowiki>mod:file</nowiki></code> means <code><nowiki>assets/mod/models/file</nowiki></code> in one context but <code><nowiki>assets/mod/textures/file</nowiki></code> in another. When something is described as requiring a <code>ResourceLocation</code>, it will be defined what exactly the path means.

All strings related to the model system (especially <code>ResourceLocations</code>) should be in snake case (<code>meaning_all_lowercase_and_underscore_separated_words_like_this</code>).