tutorial:registry
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:registry [2020/08/26 09:30] – Fix getId description elisezerotwo | tutorial:registry [2023/05/15 03:31] (current) – Fix missing period in code. phanabani | ||
---|---|---|---|
Line 9: | Line 9: | ||
* Abstracting or hiding numerical IDs | * Abstracting or hiding numerical IDs | ||
- | When registering any type of content, you pass in an '' | + | When registering any type of content, you pass in an '' |
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. | 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. | ||
Line 15: | Line 15: | ||
===== Registry Types ===== | ===== 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 '' | + | 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 '' |
For a deeper overview and description of all available registries, read the [[tutorial: | For a deeper overview and description of all available registries, read the [[tutorial: | ||
Line 21: | Line 21: | ||
===== Registering Content ===== | ===== Registering Content ===== | ||
- | Use '' | + | Use '' |
- | <code java> | + | <yarncode |
- | public static <T> T register(Registry<? super T> registry, | + | public static <T> T method_10230(class_2378<? super T> registry, |
- | return ((MutableRegistry)registry).add(id, entry); | + | return ((class_2385)registry).method_10272(id, entry); |
} | } | ||
- | </code> | + | </yarncode> |
- | **registry** - an instance of the registry you want to add content to. A list of all vanilla registries, located in '' | + | **registry** - an instance of the registry you want to add content to. A list of all vanilla registries, located in '' |
**id** - an identifying label for your content inside the registry. Standard convention is '' | **id** - an identifying label for your content inside the registry. Standard convention is '' | ||
Line 36: | Line 36: | ||
===== Registry Methods ===== | ===== Registry Methods ===== | ||
- | '' | + | '' |
- | <code java> | + | <yarncode |
@Nullable | @Nullable | ||
- | public abstract T get(@Nullable | + | public abstract T method_10223(@Nullable |
- | </code> | + | </yarncode> |
---- | ---- | ||
- | '' | + | '' |
- | <code java> | + | <yarncode |
@Nullable | @Nullable | ||
- | public abstract | + | public abstract |
- | </code> | + | </yarncode> |
---- | ---- | ||
- | '' | + | '' |
- | <code java> | + | <yarncode |
- | public abstract int getRawId(@Nullable T entry); | + | public abstract int method_10206(@Nullable T entry); |
- | </code> | + | </yarncode> |
tutorial/registry.1598434208.txt.gz · Last modified: 2020/08/26 09:30 by elisezerotwo