====== Registry System ====== You will need to register most content you add to the game. This helps with: * Letting the game know your content exists * Verifying game content between client & server * Handling invalid content in a save * Preventing conflicts between different mods * Compression for client <-> server communication and data saving * Abstracting or hiding numerical IDs When registering any type of content, you pass in an '''', which is a label for your addition. s– often abbreviated as IDs– have a namespace and path. In most cases, the namespace is the ID of your mod, and the path is the name of the content you’re registering. For example, the standard dirt block has the ID of ''%%minecraft:dirt%%''. Using custom content without registering it can lead to buggy behavior, such as missing textures, world save issues, and crashes. The game will usually let you know if you forget to register something. ===== Registry Types ===== When registering content, you need to specify which registry you are adding content to. The base game provides registries for all vanilla content, which can be found in ''%%Registries%%'' (for 1.19.3 and above) or ''Registry'' (for below 1.19.3). Two examples of registries you may use include ''Registries.ITEM'' (for 1.19.3 above)/''Registry.ITEM'' (for 1.19.2 below) for items and ''Registries.BLOCK'' (for 1.19.3 above)/''Registry.BLOCK'' (for 1.19.2 below) for blocks. For a deeper overview and description of all available registries, read the [[tutorial:registry_types|registry types]] page. ===== Registering Content ===== Use ''.'' for adding content to registries: public static T method_10230(class_2378 registry, class_2960 id, T entry) { return ((class_2385)registry).method_10272(id, entry); } **registry** - an instance of the registry you want to add content to. A list of all vanilla registries, located in '''', can be found in the [[tutorial:registry_types|registry types]] page. **id** - an identifying label for your content inside the registry. Standard convention is ''%%modid:name%%'', as seen with ''%%minecraft:dirt%%''. **entry** - an instance of the content you want to register. ===== Registry Methods ===== '''' - returns the entry associated with an ID inside a registry. If the entry doesn’t exist, '''' returns the default registry value, and '''' returns null. @Nullable public abstract T method_10223(@Nullable class_2960 id); ---- '''' - returns the '''' associated with an entry inside a registry. If the entry doesn’t exist, '''' returns the default registry ID, and '''' returns null. @Nullable public abstract class_2960 method_10221(T entry); ---- '''' - returns the internal integer ID associated with an entry inside a registry. If the entry doesn’t exist, '''' returns the raw ID of the default registry value, and '''' returns -1. public abstract int method_10206(@Nullable T entry);