User Tools

Site Tools


tutorial:registry

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:registry [2024/08/25 13:55] – [Getting the object by ID] solidblocktutorial:registry [2024/08/25 14:06] (current) solidblock
Line 86: Line 86:
  
 A **registry entry** (''RegistryEntry'') is a wrapper of contents that belong to types that have registry. They have two types: A **registry entry** (''RegistryEntry'') is a wrapper of contents that belong to types that have registry. They have two types:
-  * ''RegistryEntry.Reference'': things that are registered in the register, and therefore have their IDs.+  * ''RegistryEntry.Reference'': things that are registered in the registry, and therefore have their IDs.
   * ''RegistryEntry.Direct'': things not registered in the register. They may be anonymously specified in some ways.   * ''RegistryEntry.Direct'': things not registered in the register. They may be anonymously specified in some ways.
  
Line 93: Line 93:
   * ''%%/loot give @s loot {pools:[{rolls:1, entries:[{type:"item", name:"minecraft:stone"}]}]}%%''   * ''%%/loot give @s loot {pools:[{rolls:1, entries:[{type:"item", name:"minecraft:stone"}]}]}%%''
  
-Both the two commands give you a stone. The former one will get the loot table ''minecraft:blocks/stone'' from the loot table registry of the world, so it is ''RegistryEntry.Reference''. The latter one will encode a loot table from a SNBT, which does not have an ID, so it is ''RegistryEntry.Direct''. Both the two type of registry entries can be fetched the actual content by calling ''value()'' method.+Both the two commands give you a stone. The former one will get the loot table ''minecraft:blocks/stone'' from the loot table registry of the world, so it is ''RegistryEntry.Reference''. The latter one will decode a loot table from a SNBT, which does not have an ID, so it is ''RegistryEntry.Direct''. Both the two type of registry entries can be fetched the actual content by calling ''value()'' method.
  
 ==== Registry entry list ==== ==== Registry entry list ====
  
-Similar to registry entries, **registry entry lists** (''RegistryEntryList'') are used in many cases and have two types:+Similar to registry entries, **registry entry lists** (''RegistryEntryList'') are used in many cases and also have two types:
   * ''RegistryEntryList.Named'': The list defined by [[tags]], which are defined in data packs.   * ''RegistryEntryList.Named'': The list defined by [[tags]], which are defined in data packs.
   * ''RegistryEntryList.Direct'': The list defirectly defined by listing all contents.   * ''RegistryEntryList.Direct'': The list defirectly defined by listing all contents.
tutorial/registry.1724594105.txt.gz · Last modified: 2024/08/25 13:55 by solidblock