<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://forge.gemwire.uk/index.php?action=history&amp;feed=atom&amp;title=Datapack_Registries</id>
	<title>Datapack Registries - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://forge.gemwire.uk/index.php?action=history&amp;feed=atom&amp;title=Datapack_Registries"/>
	<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;action=history"/>
	<updated>2026-04-30T15:05:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;diff=3370&amp;oldid=prev</id>
		<title>Xan: /* JsonCodecProvider */ Fix code error on the last line (GatherDataEvent has no method named addProvider(), this is a member of DataGenerator)</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;diff=3370&amp;oldid=prev"/>
		<updated>2022-12-18T10:51:37Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;JsonCodecProvider: &lt;/span&gt; Fix code error on the last line (GatherDataEvent has no method named addProvider(), this is a member of DataGenerator)&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:51, 18 December 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l41&quot; &gt;Line 41:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 41:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     dataGenerator, existingFileHelper, &amp;quot;modid&amp;quot;, registryOps, Registry.PLACED_FEATURE_REGISTRY, map);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     dataGenerator, existingFileHelper, &amp;quot;modid&amp;quot;, registryOps, Registry.PLACED_FEATURE_REGISTRY, map);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;event&lt;/del&gt;.addProvider(event.includeServer(), provider);&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;generator&lt;/ins&gt;.addProvider(event.includeServer(), provider);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Xan</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;diff=3308&amp;oldid=prev</id>
		<title>SciWhiz12: SciWhiz12 moved page Datageneration/Datapack Registries to Datapack Registries: by request of User:SizableShrimp</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;diff=3308&amp;oldid=prev"/>
		<updated>2022-08-13T20:37:09Z</updated>

		<summary type="html">&lt;p&gt;SciWhiz12 moved page &lt;a href=&quot;/wiki/Datageneration/Datapack_Registries&quot; class=&quot;mw-redirect&quot; title=&quot;Datageneration/Datapack Registries&quot;&gt;Datapack Registries&lt;/a&gt; to &lt;a href=&quot;/wiki/Datapack_Registries&quot; title=&quot;Datapack Registries&quot;&gt;Datapack Registries&lt;/a&gt;: by request of &lt;a href=&quot;/wiki/User:SizableShrimp&quot; title=&quot;User:SizableShrimp&quot;&gt;User:SizableShrimp&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:37, 13 August 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en-GB&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>SciWhiz12</name></author>
	</entry>
	<entry>
		<id>https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;diff=3273&amp;oldid=prev</id>
		<title>Commoble: Created page with &quot;Datapack Registries (sometimes called dynamic registries or worldgen registries) are a set of registries that are able to load data from JSONS when a server starts. These incl...&quot;</title>
		<link rel="alternate" type="text/html" href="https://forge.gemwire.uk/index.php?title=Datapack_Registries&amp;diff=3273&amp;oldid=prev"/>
		<updated>2022-06-15T00:49:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;Datapack Registries (sometimes called dynamic registries or worldgen registries) are a set of registries that are able to load data from JSONS when a server starts. These incl...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Datapack Registries (sometimes called dynamic registries or worldgen registries) are a set of registries that are able to load data from JSONS when a server starts. These include all vanilla registries enumerated in RegistryAccess.REGISTRIES (such as biomes, placed features, and dimensiontypes) as well as any [[Registration#Creating_Custom_Registries|custom forge registry]] marked with &amp;lt;code&amp;gt;datapackRegistry()&amp;lt;/code&amp;gt; in its registry builder (such as forge's [[Biome Modifiers]] and Structure Modifiers).&lt;br /&gt;
&lt;br /&gt;
These registries have the ability to have their objects registered in Java ''or'' defined in JSON.&lt;br /&gt;
&lt;br /&gt;
If a mod ships a JSON for a datapack registry element in its builtin datapack, then it is not necessary for that mod to register the object in java; however, it is also possible to create the object during GatherDataEvent and datagenerate the JSON.&lt;br /&gt;
&lt;br /&gt;
All datapack registries are automatically datagenerable; each registry has a [[Codecs|Codec]] registered to it, which defines the serialization, and each registry's registry id determines its json directory. Elements of vanilla registries are loaded from &amp;lt;code&amp;gt;data/{element-namespace}/{registry-path}/{element-path}.json&amp;lt;/code&amp;gt;, while elements of custom registries are loaded from &amp;lt;code&amp;gt;data/{element-namespace}/{registry-namespace}/{registry-path}/{element-path}.json&amp;lt;/code&amp;gt;, using the namespace and path of the registry and the element.&lt;br /&gt;
&lt;br /&gt;
= RegistryOps and RegistryAccess =&lt;br /&gt;
&lt;br /&gt;
RegistryOps is a special [[DynamicOps]] made specifically for de/serializing datapack registries; it provides additional registry context and enables the use of special codecs that can only be used with RegistryOps. Datageneration of datapack registry elements must always be done using RegistryOps to convert elements to JsonElements.&lt;br /&gt;
&lt;br /&gt;
RegistryOps can be created via &amp;lt;code&amp;gt;RegistryOps.create(JsonElement.INSTANCE, RegistryAccess.builtinCopy())&amp;lt;/code&amp;gt;. RegistryAccess.builtinCopy() creates a set of writable datapack registries, which is necessary for datagenerating unregistered objects. All datageneration done in a GatherDataEvent handler must use the same RegistryAccess/RegistryOps instances (trying to encode an object in one set of registries that refers to an object in another set of registries will fail with strange holder errors).&lt;br /&gt;
&lt;br /&gt;
== Holders ==&lt;br /&gt;
&lt;br /&gt;
A Holder vaguely resembles a Pair&amp;lt;Key, Value&amp;gt; that either starts with a key and has a value bound later, or starts with a value and may have a key bound later.&lt;br /&gt;
&lt;br /&gt;
Many datapack registry elements must be constructed with Holders that refer to elements of other registries; for example, PlacedFeatures are constructed with a Holder of a ConfiguredFeature. When datagenerating objects, we can use &amp;lt;code&amp;gt;RegistryOps#registry&amp;lt;/code&amp;gt; to get a registry and &amp;lt;code&amp;gt;Registry#getOrCreateHolderOrThrow&amp;lt;/code&amp;gt; to produce key-only reference holders (the key being the only part of the holder we need, as holder codecs encode only the key of the holder when using a RegistryOps).&lt;br /&gt;
&lt;br /&gt;
Holders referring to datapack registry elements must be retrieved from the RegistryAccess/RegistryOps that will be used for datageneration; holders referring to static registry elements (such as blocks) can come directly from a ForgeRegistry as e.g. there is only ever one registry for blocks.&lt;br /&gt;
&lt;br /&gt;
= JsonCodecProvider =&lt;br /&gt;
&lt;br /&gt;
Forge provides a dataprovider for datapack registry elements that, given a registry key and a map of objects to datagenerate, datagenerates all elements in the map to the locations determined by their keys.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
void onGatherData(GatherDataEvent event)&lt;br /&gt;
{&lt;br /&gt;
  DataGenerator generator = event.getDataGenerator();&lt;br /&gt;
  ExistingFileHelper existingFileHelper = event.getExistingFileHelper();&lt;br /&gt;
  RegistryAccess registryAccess = RegistryAccess.builtinCopy();&lt;br /&gt;
  RegistryOps&amp;lt;JsonElement&amp;gt; registryOps = RegistryOps.create(JsonOps.INSTANCE, registryAccess);&lt;br /&gt;
&lt;br /&gt;
  ResourceLocation placedFeatureRL = new ResourceLocation(&amp;quot;modid&amp;quot;, &amp;quot;sponge_everywhere&amp;quot;);&lt;br /&gt;
  PlacedFeature placedFeature = new PlacedFeature(//etc;)&lt;br /&gt;
  // All placed features to be datagenerated can be in the map&lt;br /&gt;
  Map&amp;lt;ResourceLocation, PlacedFeature&amp;gt; map = Map.of(placedFeatureRL, placedFeature);&lt;br /&gt;
&lt;br /&gt;
  JsonCodecProvider provider = JsonCodecProvider.forDatapackRegistry(&lt;br /&gt;
    dataGenerator, existingFileHelper, &amp;quot;modid&amp;quot;, registryOps, Registry.PLACED_FEATURE_REGISTRY, map);&lt;br /&gt;
&lt;br /&gt;
  event.addProvider(event.includeServer(), provider);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Commoble</name></author>
	</entry>
</feed>