5,789 bytes added
, 07:45, 10 June 2022
A resource is extra data used by the game, and is stored in a data file, instead of being in the code. Minecraft has two primary resource systems active: one on the client used for visuals such as models, textures, and localization called <code><nowiki>assets</nowiki></code>, the other used for gameplay such as recipes and loot tables called <code><nowiki>data</nowiki></code>. Resource packs control the former, while data packs control the latter.
When multiple resource packs or data packs are enabled, they are merged. Generally, files from packs at the top of the stack override those below; however, for certain files, such as localization files and tags, data is actually merged contentwise. Mods actually define resource and data packs too, in their <code><nowiki>resources</nowiki></code> directories, but they are seen as subsets of the “Default” pack. Mod resource packs cannot be disabled, but they can be overridden by other resource packs. Mod datapacks can be disabled with the vanilla <code><nowiki>/datapack</nowiki></code> command.
All resources should have '''snake case''' paths and filenames (lowercase, using “_” for word boundaries).
== ResourceLocation ==
Minecraft identifies resources using <code><nowiki>ResourceLocation</nowiki></code>s. A <code><nowiki>ResourceLocation</nowiki></code> contains two parts: a namespace and a path. It generally points to the resource at <code><nowiki><assets|data>/<namespace>/<ctx>/<path></nowiki></code>, where <code><nowiki>ctx</nowiki></code> is a context-specific path fragment that depends on how the ResourceLocation is being used. When a <code><nowiki>ResourceLocation</nowiki></code> is written from/read as a string, it is seen as <code><nowiki><namespace>:<path></nowiki></code>. If the namespace and the colon are left out, then when the string is read into an ResourceLocation the namespace will almost always default to <code><nowiki>minecraft</nowiki></code>. A mod should put its resources into a namespace with the same name as its modid (E.g. a mod with id <code><nowiki>examplemod</nowiki></code> should place its resources in <code><nowiki><assets|data>/examplemod</nowiki></code>, and <code><nowiki>ResourceLocation</nowiki></code>s pointing to those files would look like <code><nowiki>examplemod:<path></nowiki></code>). This is not a requirement, and in some cases it can be desirable to use a different (or even more than one) namespace. <code><nowiki>ResourceLocation</nowiki></code>s are used outside the resource system, too, as they happen to be a great way to uniquely identify objects (e.g. [[Registration/1.18|registries]]).
== Important Directories ==
Minecraft expects certain parts of your project to be in certain locations, such as textures and JSONs.
All locations and items covered in this page are relative to your <code><nowiki>./src/main/resources/</nowiki></code> directory.
== General Files ==
=== mods.toml ===
The <code><nowiki>mods.toml</nowiki></code> file is in the <code><nowiki>./META-INF/</nowiki></code> directory. This holds the basic information relating to your mod.
=== pack.mcmeta ===
The <code><nowiki>pack.mcmeta</nowiki></code> file is in the current directory. This allows Minecraft to notice the assets provided by your mod.
== Assets ==
The <code><nowiki>./assets</nowiki></code> folder holds all client related files for a specific user. These files are only specific to the computer they're on.
=== Blockstates ===
Blockstate definition files are in the JSON format and are in the <code><nowiki>./assets/<modid>/blockstates/</nowiki></code> folder.
=== Localizations ===
Localizations are plain-text files with the file extension <code><nowiki>.json</nowiki></code> and the name being their [https://docs.microsoft.com/en-us/previous-versions/commerce-server/ee825488(v=cs.20)?redirectedfrom=MSDN language code] in lowercase such as <code><nowiki>en_us</nowiki></code>.
They are located in the <code><nowiki>./assets/<modid>/lang/</nowiki></code> folder.
=== Models ===
Model files are in JSON format and are located in <code><nowiki>./assets/<modid>/models/block/</nowiki></code> or <code><nowiki>./assets/<modid>/models/item/</nowiki></code> depending on whether they are for a block or an item, respectively.
=== Textures ===
Textures are in the PNG format and are located in <code><nowiki>./assets/<modid>/textures/block/</nowiki></code> or <code><nowiki>./assets/<modid>/textures/item/</nowiki></code> depending on whether they are for a block or an item, respectively. For other entries, they will be placed in their specified location within <code><nowiki>./assets/<modid>/textures/</nowiki></code>.
== Data ==
The <code><nowiki>./data</nowiki></code> folder holds all server related files for a specific game file. These files are synced across the network from the hosting server location.
=== Advancements ===
Advancements are in JSON format and are located in <code><nowiki>./data/<modid>/advancements/<group>/</nowiki></code> where <code><nowiki>group</nowiki></code> is the tab the advancement is part of.
=== Loot Tables ===
Loot tables are in JSON format and are located in <code><nowiki>./data/<modid>/loot_tables/<group>/</nowiki></code> where <code><nowiki>group</nowiki></code> is the general object where the loot table drops from (e.g. a block's loot table is in <code><nowiki>blocks</nowiki></code>).
=== Recipes ===
Recipes are in JSON format and are located in <code><nowiki>./data/<modid>/recipes/</nowiki></code>.
=== Tags ===
Tags are in JSON format and are located in <code><nowiki>./data/<modid>/tags/<group>/</nowiki></code> where <code><nowiki>group</nowiki></code> is the registry object to create the tags for (e.g. an entity tag would be in <code><nowiki>entity_types</nowiki></code>).