Package commoble.databuddy.datagen

# Record Class DynamicRegistryDataGenerator

java.lang.Object
java.lang.Record
commoble.databuddy.datagen.DynamicRegistryDataGenerator

public record DynamicRegistryDataGenerator(net.minecraft.data.DataGenerator generator, net.minecraft.resources.RegistryOps<com.google.gson.JsonElement> ops) extends Record
Helper for datagenerating jsons to be loaded into the dynamic/datapack registries (e.g. biomes and configured features).
How to use it:

1. Use `DeferredRegister`s to register objects to `BuiltinRegistries`. These can be registered during datagen, objects to be read from json do not need to be registered during normal client/server init. However, any dynamic registry json referenced by the registered objects you generate must also itself be registered (e.g. if a placed feature references a configured feature, in order for the placed feature to be generated, both the placed feature and the configured feature must be registered during the datagen session).
2. Create a DynamicRegistryDataGenerator
3. For each type (registry) of object to be datagenerated, use makeDataProvider to create a datagenerator and add it to the `GatherDataEvent`'s datagenerator

## Constructor Summary

Constructors
Constructor
Description
`DynamicRegistryDataGenerator(net.minecraft.data.DataGenerator generator, net.minecraft.resources.RegistryOps<com.google.gson.JsonElement> ops)`
Creates an instance of a `DynamicRegistryDataGenerator` record class.

## Method Summary

Modifier and Type
Method
Description
`static DynamicRegistryDataGenerator`
`create(net.minecraft.data.DataGenerator generator)`
Helper for creating the DynamicRegistryDataGenerator in the preferred manner.
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`net.minecraft.data.DataGenerator`
`generator()`
Returns the value of the `generator` record component.
`final int`
`hashCode()`
Returns a hash code value for this object.
`final <T> net.minecraft.data.DataProvider`
`makeDataProvider(String modid, com.google.gson.Gson gson, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, net.minecraft.resources.ResourceKey<T>... keys)`
Creates a dataprovider that generates a json file for each specified resource key.
`final <T> net.minecraft.data.DataProvider`
`makeDataProvider(String modid, com.google.gson.Gson gson, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceKey<T>... keys)`
Creates a dataprovider that generates a json file for each specified resource key.
Uses the default codec specified in `RegistryAccess` for the given registry.
`net.minecraft.resources.RegistryOps<com.google.gson.JsonElement>`
`ops()`
Returns the value of the `ops` record component.
`final String`
`toString()`
Returns a string representation of this record class.

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### DynamicRegistryDataGenerator

public DynamicRegistryDataGenerator(net.minecraft.data.DataGenerator generator, net.minecraft.resources.RegistryOps<com.google.gson.JsonElement> ops)
Creates an instance of a `DynamicRegistryDataGenerator` record class.

Parameters:
  `generator` - the value for the `generator` record component
  `ops` - the value for the `ops` record component

## Method Details

### create

public static DynamicRegistryDataGenerator create(net.minecraft.data.DataGenerator generator)
Helper for creating the DynamicRegistryDataGenerator in the preferred manner.

Parameters:
  `generator` - The DataGenerator provided from the `GatherDataEvent`
Returns:
  A DynamicRegistryDataGenerator with a registryops baked into it.

### makeDataProvider

@SafeVarargs public final <T> net.minecraft.data.DataProvider makeDataProvider(String modid, com.google.gson.Gson gson, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, net.minecraft.resources.ResourceKey<T>... keys)
Creates a dataprovider that generates a json file for each specified resource key.
Uses the default codec specified in `RegistryAccess` for the given registry.

Type Parameters:
  `T` - The type of json object to generate, e.g. Biome, ConfiguredFeature, etc
Parameters:
  `modid` - Used for logging purposes, does not affect the namespace of generated files
  `gson` - The gson to use to format and output the json
  `registryKey` - The key to the registry to use. Vanilla builtin registry keys are all constants in `Registry`.
  `keys` - Resource keys identifying the objects to generate jsons for.
  Each object identified by these keys must have been previously registered to the `BuiltinRegistries`.
  Using a deferred register created via `DeferredRegister.create(ResourceKey, String)` is the preferred way to do this.
Returns:
  A data provider that can be given to `DataGenerator.addProvider(DataProvider)` during the `GatherDataEvent`.

### makeDataProvider

@SafeVarargs public final <T> net.minecraft.data.DataProvider makeDataProvider(String modid, com.google.gson.Gson gson, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registryKey, com.mojang.serialization.Codec<T> codec, net.minecraft.resources.ResourceKey<T>... keys)
Creates a dataprovider that generates a json file for each specified resource key.

Type Parameters:
  `T` - The type of json object to generate, e.g. Biome, ConfiguredFeature, etc
Parameters:
  `modid` - Used for logging purposes, does not affect the namespace of generated files
  `gson` - The gson to use to format and output the json
  `registryKey` - The key to the registry to use. Vanilla builtin registry keys are all constants in `Registry`.
  `codec` - The codec to use to encode objects to json, e.g. `Biome.DIRECT_CODEC`.
  `keys` - Resource keys identifying the objects to generate jsons for.
  Each object identified by these keys must have been previously registered to the `BuiltinRegistries`.
  Using a deferred register created via `DeferredRegister.create(ResourceKey, String)` is the preferred way to do this.
Returns:
  A data provider that can be given to `DataGenerator.addProvider(DataProvider)` during the `GatherDataEvent`.

### toString

public final String toString()
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.

Specified by:
  `toString` in class `Record`
Returns:
  a string representation of this object

### hashCode

public final int hashCode()
Returns a hash code value for this object. The value is derived from the hash code of each of the record components.

Specified by:
  `hashCode` in class `Record`
Returns:
  a hash code value for this object

### equals

public final boolean equals(Object o)
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with `Objects::equals(Object,Object)`.

Specified by:
  `equals` in class `Record`
Parameters:
  `o` - the object with which to compare
Returns:
  `true` if this object is the same as the `o` argument; `false` otherwise.

### generator

public net.minecraft.data.DataGenerator generator()
Returns the value of the `generator` record component.

Returns:
  the value of the `generator` record component

### ops

public net.minecraft.resources.RegistryOps<com.google.gson.JsonElement> ops()
Returns the value of the `ops` record component.

Returns:
  the value of the `ops` record component