Package net.commoble.databuddy.codec

# Record Class RegistryDispatcher<T>

java.lang.Object
java.lang.Record
net.commoble.databuddy.codec.RegistryDispatcher<T>

Type Parameters:
  `T` - Data type -- the things that get parsed from jsons
Record Components:
  `dispatcherCodec` - The codec for the serializer type.
  `dispatchedCodec` - The codec for the data type (this is what you would use for reading/writing json data)
  `defreg` - The primary DeferredRegister for the serializer registry. Should only be used by the mod that created the registry.
  `codecRegistry` - The backing serializer registry

public record RegistryDispatcher<T>(com.mojang.serialization.Codec<com.mojang.serialization.MapCodec<? extends T>> dispatcherCodec, com.mojang.serialization.Codec<T> dispatchedCodec, net.neoforged.neoforge.registries.DeferredRegister<com.mojang.serialization.MapCodec<? extends T>> defreg, net.minecraft.core.Registry<com.mojang.serialization.MapCodec<? extends T>> codecRegistry) extends Record
Helper for creating a deferred register and dispatch codec for a custom registry of serializer types. This allows you to register serializers for type-dispatched data, e.g. consider the following json:

     {
       "type": "yourmod:sometype"
       "data": 5
     }

Here, "yourmod:sometype" refers to a registered codec that defines how to read the rest of the json object.

## Constructor Summary

Constructors
Constructor
Description
`RegistryDispatcher(com.mojang.serialization.Codec<com.mojang.serialization.MapCodec<? extends T>> dispatcherCodec, com.mojang.serialization.Codec<T> dispatchedCodec, net.neoforged.neoforge.registries.DeferredRegister<com.mojang.serialization.MapCodec<? extends T>> defreg, net.minecraft.core.Registry<com.mojang.serialization.MapCodec<? extends T>> codecRegistry)`
Creates an instance of a `RegistryDispatcher` record class.

## Method Summary

Modifier and Type
Method
Description
`net.minecraft.core.Registry<com.mojang.serialization.MapCodec<? extends T>>`
`codecRegistry()`
Returns the value of the `codecRegistry` record component.
`net.neoforged.neoforge.registries.DeferredRegister<com.mojang.serialization.MapCodec<? extends T>>`
`defreg()`
Returns the value of the `defreg` record component.
`com.mojang.serialization.Codec<T>`
`dispatchedCodec()`
Returns the value of the `dispatchedCodec` record component.
`com.mojang.serialization.Codec<com.mojang.serialization.MapCodec<? extends T>>`
`dispatcherCodec()`
Returns the value of the `dispatcherCodec` record component.
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`final int`
`hashCode()`
Returns a hash code value for this object.
`static <T> RegistryDispatcher<T>`
`makeDispatchForgeRegistry(net.minecraft.resources.ResourceLocation registryId, Function<T,? extends com.mojang.serialization.MapCodec<? extends T>> typeLookup, Consumer<net.neoforged.neoforge.registries.RegistryBuilder<com.mojang.serialization.MapCodec<? extends T>>> extraSettings)`
Helper method for creating and registering a DeferredRegister for a registry of serializers.
`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

### RegistryDispatcher

public RegistryDispatcher(com.mojang.serialization.Codec<com.mojang.serialization.MapCodec<? extends T>> dispatcherCodec, com.mojang.serialization.Codec<T> dispatchedCodec, net.neoforged.neoforge.registries.DeferredRegister<com.mojang.serialization.MapCodec<? extends T>> defreg, net.minecraft.core.Registry<com.mojang.serialization.MapCodec<? extends T>> codecRegistry)
Creates an instance of a `RegistryDispatcher` record class.

Parameters:
  `dispatcherCodec` - the value for the `dispatcherCodec` record component
  `dispatchedCodec` - the value for the `dispatchedCodec` record component
  `defreg` - the value for the `defreg` record component
  `codecRegistry` - the value for the `codecRegistry` record component

## Method Details

### makeDispatchForgeRegistry

public static <T> RegistryDispatcher<T> makeDispatchForgeRegistry(net.minecraft.resources.ResourceLocation registryId, Function<T,? extends com.mojang.serialization.MapCodec<? extends T>> typeLookup, Consumer<net.neoforged.neoforge.registries.RegistryBuilder<com.mojang.serialization.MapCodec<? extends T>>> extraSettings)
Helper method for creating and registering a DeferredRegister for a registry of serializers.

Type Parameters:
  `T` - Data type -- the things that get parsed from jsons
Parameters:
  `registryId` - The ID of your registry. Names should be singular to follow mojang's naming convention, e.g. "block", "bird"
  `typeLookup` - A function to get the registered serializer for a given T (e.g. RuleTest::getType)
  `extraSettings` - Additional registry configuration if necessary.
Returns:
  Dispatch codec and a DeferredRegister for a new custom registry of serializers; the deferred register will have been subscribed, and a forge registry will be created for it.

### 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.

### dispatcherCodec

public com.mojang.serialization.Codec<com.mojang.serialization.MapCodec<? extends T>> dispatcherCodec()
Returns the value of the `dispatcherCodec` record component.

Returns:
  the value of the `dispatcherCodec` record component

### dispatchedCodec

public com.mojang.serialization.Codec<T> dispatchedCodec()
Returns the value of the `dispatchedCodec` record component.

Returns:
  the value of the `dispatchedCodec` record component

### defreg

public net.neoforged.neoforge.registries.DeferredRegister<com.mojang.serialization.MapCodec<? extends T>> defreg()
Returns the value of the `defreg` record component.

Returns:
  the value of the `defreg` record component

### codecRegistry

public net.minecraft.core.Registry<com.mojang.serialization.MapCodec<? extends T>> codecRegistry()
Returns the value of the `codecRegistry` record component.

Returns:
  the value of the `codecRegistry` record component