Interface DataMapValueMerger<R,T>

Type Parameters:
R - the type of the registry this merger is for
T - the data type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface DataMapValueMerger<R,T>
An interface used to merge two conflicting registry data map values attached to the same object.
Using a merger you can, for example, merge list data maps that come from different sources, when otherwise the newest entry would win and override the older one.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T, R> DataMapValueMerger<R,T>
    Returns a default merger that overrides the old value with the new one.
    static <T, R> DataMapValueMerger<R,List<T>>
    Returns a default merger that merges list data.
    static <K, V, R> DataMapValueMerger<R,Map<K,V>>
    Returns a default merger that merges map data.
    merge(net.minecraft.core.Registry<R> registry, com.mojang.datafixers.util.Either<net.minecraft.tags.TagKey<R>,net.minecraft.resources.ResourceKey<R>> first, T firstValue, com.mojang.datafixers.util.Either<net.minecraft.tags.TagKey<R>,net.minecraft.resources.ResourceKey<R>> second, T secondValue)
    Merge two conflicting data map values.
    static <T, R> DataMapValueMerger<R,Set<T>>
    Returns a default merger that merges set data.
  • Method Details

    • merge

      T merge(net.minecraft.core.Registry<R> registry, com.mojang.datafixers.util.Either<net.minecraft.tags.TagKey<R>,net.minecraft.resources.ResourceKey<R>> first, T firstValue, com.mojang.datafixers.util.Either<net.minecraft.tags.TagKey<R>,net.minecraft.resources.ResourceKey<R>> second, T secondValue)
      Merge two conflicting data map values.
      Parameters:
      registry - the registry the data is for
      first - the source of the first (older) value
      firstValue - the first (older) value
      second - the source of the second (newer) value
      secondValue - the second (newer) value
      Returns:
      the merged value
    • defaultMerger

      static <T, R> DataMapValueMerger<R,T> defaultMerger()
      Returns a default merger that overrides the old value with the new one.
      Returns:
      a default merger that overrides the old value with the new one
    • listMerger

      static <T, R> DataMapValueMerger<R,List<T>> listMerger()
      Returns a default merger that merges list data.
      Returns:
      a default merger that merges list data
    • setMerger

      static <T, R> DataMapValueMerger<R,Set<T>> setMerger()
      Returns a default merger that merges set data.
      Returns:
      a default merger that merges set data
    • mapMerger

      static <K, V, R> DataMapValueMerger<R,Map<K,V>> mapMerger()
      Returns a default merger that merges map data.
      Returns:
      a default merger that merges map data