Class AdvancedDataMapType<R,T,VR extends DataMapValueRemover<R,T>>
java.lang.Object
net.neoforged.neoforge.registries.datamaps.DataMapType<R,T>
net.neoforged.neoforge.registries.datamaps.AdvancedDataMapType<R,T,VR>
- Type Parameters:
R- the type of the attached dataT- the registry typeVR- the type of the remover
public final class AdvancedDataMapType<R,T,VR extends DataMapValueRemover<R,T>>
extends DataMapType<R,T>
A version of
data map types that has two more features for compatibility and conflict handling: mergers and removers.
A remover will be used to support targeted removals that
support decomposition, instead of the removal of the entire value. That way, for instance, one is able to remove just a value with
a specific key from a map-based data map, instead of the entire map.
To use a remover one has to change the structure of the remove list, to an object:
"remove": {
"someobject:someid": {} // Remover object
}
Or, to an object list:
"remove": [
{
"key": someobject:someid",
"remover": {} // Remover object. Optional. If not provided, the attached value will be removed from the object completely, without invoking the remover
}
]
Advanced data map types also have the ability of handling conflicts between datapacks that attach an object to the same registry object.
Using mergers, collection-based data maps can, as such, merge values provided by multiple packs
in the same collection.
The default merge will however have the overriding behaviour of "last come wins", similar to recipes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAdvancedDataMapType.Builder<T,R, VR extends DataMapValueRemover<R, T>> A builder foradvanced data map types. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAdvancedDataMapType(ResourceKey<Registry<R>> registryKey, ResourceLocation id, com.mojang.serialization.Codec<T> codec, @Nullable com.mojang.serialization.Codec<T> networkCodec, boolean mandatorySync, com.mojang.serialization.Codec<VR> remover, DataMapValueMerger<R, T> merger) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R> AdvancedDataMapType.Builder <T, R, DataMapValueRemover.Default<T, R>> builder(ResourceLocation id, ResourceKey<Registry<R>> registry, com.mojang.serialization.Codec<T> codec) Returns an advanced data map type builder.merger()Returns the merger that handles data map conflicts.com.mojang.serialization.Codec<VR> remover()Returns the codec used to create removers.Methods inherited from class net.neoforged.neoforge.registries.datamaps.DataMapType
codec, id, mandatorySync, networkCodec, registryKey
-
Field Details
-
remover
-
merger
-
-
Constructor Details
-
AdvancedDataMapType
private AdvancedDataMapType(ResourceKey<Registry<R>> registryKey, ResourceLocation id, com.mojang.serialization.Codec<T> codec, @Nullable @Nullable com.mojang.serialization.Codec<T> networkCodec, boolean mandatorySync, com.mojang.serialization.Codec<VR> remover, DataMapValueMerger<R, T> merger)
-
-
Method Details
-
remover
Returns the codec used to create removers.- Returns:
- the codec used to create removers
-
merger
Returns the merger that handles data map conflicts.- Returns:
- the merger that handles data map conflicts
-
builder
public static <T,R> AdvancedDataMapType.Builder<T,R, builderDataMapValueRemover.Default<T, R>> (ResourceLocation id, ResourceKey<Registry<R>> registry, com.mojang.serialization.Codec<T> codec) Returns an advanced data map type builder.- Type Parameters:
T- the type of the data mapR- the registry the data is for- Parameters:
id- the ID of the data mapregistry- the key of the registry the data map is forcodec- the codec used to deserialize the values from JSON- Returns:
- an advanced data map type builder
-