Class NotHolderSet<T>

java.lang.Object
net.neoforged.neoforge.registries.holdersets.NotHolderSet<T>
All Implemented Interfaces:
Iterable<net.minecraft.core.Holder<T>>, net.minecraft.core.HolderSet<T>, IHolderSetExtension<T>, ICustomHolderSet<T>

public class NotHolderSet<T> extends Object implements ICustomHolderSet<T>

Holderset that represents all elements of a registry not present in another holderset. neoforge:exclusion is preferable when the number of allowed elements is small relative to the size of the registry. Json format:

 {
   "type": "neoforge:not",
   "value": "not_this_holderset" // string, list, or object
 }
 
  • Field Details

    • owners

      private final List<Runnable> owners
    • registryLookup

      private final net.minecraft.core.HolderLookup.RegistryLookup<T> registryLookup
    • value

      private final net.minecraft.core.HolderSet<T> value
    • list

      @Nullable private @Nullable List<net.minecraft.core.Holder<T>> list
  • Constructor Details

    • NotHolderSet

      public NotHolderSet(net.minecraft.core.HolderLookup.RegistryLookup<T> registryLookup, net.minecraft.core.HolderSet<T> value)
  • Method Details

    • registryLookup

      public net.minecraft.core.HolderLookup.RegistryLookup<T> registryLookup()
    • value

      public net.minecraft.core.HolderSet<T> value()
    • type

      public HolderSetType type()
      Description copied from interface: ICustomHolderSet
      Returns HolderSetType registered to
      invalid reference
      ForgeRegistries.HOLDER_SET_TYPES
      .
      Specified by:
      type in interface ICustomHolderSet<T>
      Returns:
      HolderSetType registered to
      invalid reference
      ForgeRegistries.HOLDER_SET_TYPES
    • addInvalidationListener

      public void addInvalidationListener(Runnable runnable)
      Description copied from interface: 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.

      Specified by:
      addInvalidationListener in interface IHolderSetExtension<T>
      Parameters:
      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.
    • iterator

      public Iterator<net.minecraft.core.Holder<T>> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • stream

      public Stream<net.minecraft.core.Holder<T>> stream()
      Specified by:
      stream in interface net.minecraft.core.HolderSet<T>
    • size

      public int size()
      Specified by:
      size in interface net.minecraft.core.HolderSet<T>
    • unwrap

      public com.mojang.datafixers.util.Either<net.minecraft.tags.TagKey<T>,List<net.minecraft.core.Holder<T>>> unwrap()
      Specified by:
      unwrap in interface net.minecraft.core.HolderSet<T>
    • getRandomElement

      public Optional<net.minecraft.core.Holder<T>> getRandomElement(net.minecraft.util.RandomSource random)
      Specified by:
      getRandomElement in interface net.minecraft.core.HolderSet<T>
    • get

      public net.minecraft.core.Holder<T> get(int i)
      Specified by:
      get in interface net.minecraft.core.HolderSet<T>
    • contains

      public boolean contains(net.minecraft.core.Holder<T> holder)
      Specified by:
      contains in interface net.minecraft.core.HolderSet<T>
    • canSerializeIn

      public boolean canSerializeIn(net.minecraft.core.HolderOwner<T> holderOwner)
      Specified by:
      canSerializeIn in interface net.minecraft.core.HolderSet<T>
    • unwrapKey

      public Optional<net.minecraft.tags.TagKey<T>> unwrapKey()
      Specified by:
      unwrapKey in interface net.minecraft.core.HolderSet<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getList

      private List<net.minecraft.core.Holder<T>> getList()
    • invalidate

      private void invalidate()
    • isBound

      public boolean isBound()
      Specified by:
      isBound in interface net.minecraft.core.HolderSet<T>