接口 DataMapValueMerger<R,T>

类型参数:
R - the type of the registry this merger is for
T - the data type
函数接口:
这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。

@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.
API Note:
This is only useful for AdvancedDataMapType.
  • 方法详细资料

    • merge

      T merge(Registry<R> registry, com.mojang.datafixers.util.Either<TagKey<R>,ResourceKey<R>> first, T firstValue, com.mojang.datafixers.util.Either<TagKey<R>,ResourceKey<R>> second, T secondValue)
      Merge two conflicting data map values.
      参数:
      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
      返回:
      the merged value
    • defaultMerger

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

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

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

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