类 CompositeHolderSet<T>

java.lang.Object
net.neoforged.neoforge.registries.holdersets.CompositeHolderSet<T>
所有已实现的接口:
Iterable<Holder<T>>, HolderSet<T>, IHolderSetExtension<T>, ICustomHolderSet<T>
直接已知子类:
AndHolderSet, OrHolderSet

public abstract class CompositeHolderSet<T> extends Object implements ICustomHolderSet<T>
Composite holdersets have component holdersets and possibly owner holdersets (which have this holderset as a component). When their component holderset(s) invalidate, they clear any cached data and then invalidate their owner holdersets.
  • 字段详细资料

  • 构造器详细资料

    • CompositeHolderSet

      public CompositeHolderSet(List<HolderSet<T>> components)
  • 方法详细资料

    • createSet

      protected abstract Set<Holder<T>> createSet()
      返回 immutable Set of Holders given this composite holderset's component holdersets。
      返回:
      immutable Set of Holders given this composite holderset's component holdersets
    • getComponents

      public List<HolderSet<T>> getComponents()
    • getSet

      public Set<Holder<T>> getSet()
    • getList

      public List<Holder<T>> getList()
    • addInvalidationListener

      public void addInvalidationListener(Runnable runnable)
      从接口复制的说明: IHolderSetExtension

      Adds a callback to run when this holderset's contents invalidate (i.e. because tags were rebound).

      The intended usage and use case is with composite holdersets that need to cache sets/list based on other holdersets, which may be mutable (because they are tag-based or themselves composite holdersets). Composite holdersets should use this to add callbacks to each of their component holdersets when constructed.

      指定者:
      addInvalidationListener 在接口中 IHolderSetExtension<T>
      参数:
      runnable - Runnable to invoke when this component holderset's contents are no longer valid. This runnable should only clear caches and allow them to be lazily reevaluated later, as not all tag holdersets may have been rebound when this is called. This runnable should also invalidate all of the caller's listeners.
    • invalidate

      private void invalidate()
    • stream

      public Stream<Holder<T>> stream()
      指定者:
      stream 在接口中 HolderSet<T>
    • size

      public int size()
      指定者:
      size 在接口中 HolderSet<T>
    • unwrap

      public com.mojang.datafixers.util.Either<TagKey<T>,List<Holder<T>>> unwrap()
      指定者:
      unwrap 在接口中 HolderSet<T>
    • getRandomElement

      public Optional<Holder<T>> getRandomElement(RandomSource rand)
      指定者:
      getRandomElement 在接口中 HolderSet<T>
    • get

      public Holder<T> get(int i)
      指定者:
      get 在接口中 HolderSet<T>
    • contains

      public boolean contains(Holder<T> holder)
      指定者:
      contains 在接口中 HolderSet<T>
    • canSerializeIn

      public boolean canSerializeIn(HolderOwner<T> holderOwner)
      指定者:
      canSerializeIn 在接口中 HolderSet<T>
    • unwrapKey

      public Optional<TagKey<T>> unwrapKey()
      指定者:
      unwrapKey 在接口中 HolderSet<T>
    • iterator

      public Iterator<Holder<T>> iterator()
      指定者:
      iterator 在接口中 Iterable<T>
    • homogenize

      public List<HolderSet<T>> homogenize()
      Maps the sub-holdersets of this composite such that, if the list contains more than one element, and is non-homogenous, each element of the list will serialize as an object. Prevents crashes from trying to serialize non-homogenous lists to NBT. Lists are considered non-homogenous if it contains more than one serialization type of holderset. Holdersets may be serialized as strings, lists, or maps.
      返回:
      List of holdersets with homogenous serialization behavior. Returns a new List if size > 1 and serialization would be non-homogenous, otherwise returns the composite's existing List.
    • isHomogenous

      public boolean isHomogenous()
      返回:
      True if all of our sub-holdersets have the same IHolderSetExtension.SerializationType (string, list, or object). False if we have more than one holderset AND if either we have more than one serialization type among them, or any holderset is
      引用无效
      SerializationType.UNKNOWN
      .
    • isBound

      public boolean isBound()
      指定者:
      isBound 在接口中 HolderSet<T>