tutorial:registry
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:registry [2024/08/25 12:52] – solidblock | tutorial:registry [2024/08/25 14:06] (current) – solidblock | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | Minecraft uses the **registry system** to handle almost everything in the game. For mod developers, you will need to register most content you add to the game. This helps with: | + | Minecraft uses the **registry system** to handle almost everything in the game. When developing mods, you will need to register most content you add to the game. This helps with: |
* Letting the game know your content exists | * Letting the game know your content exists | ||
* Verifying game content between client & server | * Verifying game content between client & server | ||
Line 19: | Line 19: | ||
Two examples of registries you may use include '' | Two examples of registries you may use include '' | ||
- | For a deeper overview and description of all available registries, read the [[registry types]] page. | + | For a deeper overview and description of all available registries, read the '' |
===== Basic usages ===== | ===== Basic usages ===== | ||
==== Registering your content ==== | ==== Registering your content ==== | ||
- | Use ''< | + | Use ''< |
<code java> | <code java> | ||
Registry.register(registry, | Registry.register(registry, | ||
</ | </ | ||
+ | |||
* **registry** - an instance of the registry you want to add content to. | * **registry** - an instance of the registry you want to add content to. | ||
* **id** - the identifier for your content inside the registry. | * **id** - the identifier for your content inside the registry. | ||
Line 41: | Line 42: | ||
==== Getting the object by ID ==== | ==== Getting the object by ID ==== | ||
- | ''< | + | ''< |
< | < | ||
Line 52: | Line 53: | ||
Registries.ITEM.get(Identifier.ofVanilla(" | Registries.ITEM.get(Identifier.ofVanilla(" | ||
| | ||
- | Registries.ITEM.getOrEmpty(Identifier.ofVanilla(" | + | Registries.ITEM.getOrEmpty(Identifier.ofVanilla(" |
| | ||
- | Registries.ITEM.getOrEmpty(Identifier.ofVanilla(" | + | Registries.ITEM.getOrEmpty(Identifier.ofVanilla(" |
</ | </ | ||
Line 65: | Line 66: | ||
</ | </ | ||
+ | ===== Related concepts ===== | ||
+ | |||
+ | ==== Registry keys ===== | ||
+ | Some type of registries are not staticly stored in '' | ||
+ | |||
+ | However, each registry has a **registry key**, which can be found in '' | ||
+ | |||
+ | <code java> | ||
+ | final DynamicRegistryManager registryManager = world.getRegistryManager(); | ||
+ | | ||
+ | // both of the following two statements return the '' | ||
+ | registryManager.get(RegistryKeys.BIOME).get(Identifier.ofVanilla(" | ||
+ | registryManager.getWrapperOrThrow(RegistryKeys.BIOME).getOrThrow(RegistryKey.of(RegistryKeys.BIOME, | ||
+ | </ | ||
+ | |||
+ | Not only registries have registry keys. All registry contents have registry keys (as registries themselves also belong to registry contents of '' | ||
+ | |||
+ | ==== Registry entry ===== | ||
+ | |||
+ | A **registry entry** ('' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | To explicitly show the differences between two, see the following two commands: | ||
+ | * ''/ | ||
+ | * '' | ||
+ | |||
+ | Both the two commands give you a stone. The former one will get the loot table '' | ||
+ | |||
+ | ==== Registry entry list ==== | ||
+ | |||
+ | Similar to registry entries, **registry entry lists** ('' | ||
+ | * '' | ||
+ | * '' |
tutorial/registry.1724590333.txt.gz · Last modified: 2024/08/25 12:52 by solidblock