Resources/1.17

From Forge Community Wiki
Revision as of 05:51, 6 December 2021 by ShrimpBot (talk | contribs) (Copy Resources to MC1.17 archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 assets, the other used for gameplay such as recipes and loot tables called data. 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 resources 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 /datapack command.

All resources should have snake case paths and filenames (lowercase, using “_” for word boundaries).

ResourceLocation

Minecraft identifies resources using ResourceLocations. A ResourceLocation contains two parts: a namespace and a path. It generally points to the resource at <assets|data>/<namespace>/<ctx>/<path>, where ctx is a context-specific path fragment that depends on how the ResourceLocation is being used. When a ResourceLocation is written from/read as a string, it is seen as <namespace>:<path>. 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 minecraft. A mod should put its resources into a namespace with the same name as its modid (E.g. a mod with id examplemod should place its resources in <assets|data>/examplemod, and ResourceLocations pointing to those files would look like examplemod:<path>). This is not a requirement, and in some cases it can be desirable to use a different (or even more than one) namespace. ResourceLocations are used outside the resource system, too, as they happen to be a great way to uniquely identify objects (e.g. 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 ./src/main/resources/ directory.

General Files

mods.toml

The mods.toml file is in the ./META-INF/ directory. This holds the basic information relating to your mod.

pack.mcmeta

The pack.mcmeta file is in the current directory. This allows Minecraft to notice the assets provided by your mod.

Assets

The ./assets 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 ./assets/<modid>/blockstates/ folder.

Localizations

Localizations are plain-text files with the file extension .json and the name being their language code in lowercase such as en_us.

They are located in the ./assets/<modid>/lang/ folder.

Models

Model files are in JSON format and are located in ./assets/<modid>/models/block/ or ./assets/<modid>/models/item/ depending on whether they are for a block or an item, respectively.

Textures

Textures are in the PNG format and are located in ./assets/<modid>/textures/block/ or ./assets/<modid>/textures/item/ depending on whether they are for a block or an item, respectively. For other entries, they will be placed in their specified location within ./assets/<modid>/textures/.

Data

The ./data 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 ./data/<modid>/advancements/<group>/ where group is the tab the advancement is part of.

Loot Tables

Loot tables are in JSON format and are located in ./data/<modid>/loot_tables/<group>/ where group is the general object where the loot table drops from (e.g. a block's loot table is in blocks).

Recipes

Recipes are in JSON format and are located in ./data/<modid>/recipes/.

Tags

Tags are in JSON format and are located in ./data/<modid>/tags/<group>/ where group is the registry object to create the tags for (e.g. an entity tag would be in entity_types).