Class KnownTagManager<T>

java.lang.Object
com.blamejared.crafttweaker.api.tag.manager.type.KnownTagManager<T>
All Implemented Interfaces:
CommandStringDisplayable, ITagManager<KnownTag<T>>, Comparable<ITagManager<?>>, Iterable<KnownTag<T>>
Direct Known Subclasses:
EntityTypeTagManager

@ZenRegister public class KnownTagManager<T> extends Object implements ITagManager<KnownTag<T>>
  • Constructor Details

    • KnownTagManager

      public KnownTagManager(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey, Class<T> elementClass)
  • Method Details

    • elementClass

      public Optional<Class<?>> elementClass()
      Description copied from interface: ITagManager
      Gets the element type that this tag manager handles.

      This is only used to fill in type parameters, if your custom ITagManager does not have a type paremeter, you can return an empty optional.

      Specified by:
      elementClass in interface ITagManager<T>
      Returns:
      An optional class of the type of elements that this manager deals with.
    • resourceKey

      public net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey()
      Description copied from interface: ITagManager
      Gets the resource key of the registry that this manager deals with.
      Specified by:
      resourceKey in interface ITagManager<T>
      Returns:
      The resource key of the registry that this manager deals with.
    • addElements

      @SafeVarargs public final void addElements(KnownTag<T> to, T... values)
    • addId

      public void addId(KnownTag<T> to, net.minecraft.resources.ResourceLocation... values)
      Description copied from interface: ITagManager
      Adds the elements that correspond to the given ResourceLocation to the given tag.
      Specified by:
      addId in interface ITagManager<T>
      Parameters:
      to - The tag to add to.
      values - The registry key of the elements to add.
    • removeId

      public final void removeId(KnownTag<T> from, net.minecraft.resources.ResourceLocation... values)
      Description copied from interface: ITagManager
      Removes the elements that correspond to the given ResourceLocation from the given tag.
      Specified by:
      removeId in interface ITagManager<T>
      Parameters:
      from - The tag to remove from.
      values - The registry key of the elements to remove.
    • clear

      public void clear(KnownTag<T> from)
      Description copied from interface: ITagManager
      Clears all values of the given tag.
      Specified by:
      clear in interface ITagManager<T>
      Parameters:
      from - The tag to clear.
    • elements

      public List<T> elements(KnownTag<T> of)
      Gets the elements of the given tag.
      Parameters:
      of - The tag to get the elements of.
      Returns:
      The list of elements in the tag.
      DocParam:
      of <tag:items:minecraft:dirt>
    • removeElements

      @SafeVarargs public final void removeElements(KnownTag<T> from, T... values)
    • tag

      public KnownTag<T> tag(String id)
      Description copied from interface: ITagManager
      Gets a tag with the given id.
      Specified by:
      tag in interface ITagManager<T>
      Parameters:
      id - The id of the tag.
      Returns:
      A tag with the given id.
    • tag

      public KnownTag<T> tag(net.minecraft.resources.ResourceLocation id)
      Description copied from interface: ITagManager
      Gets a tag with the given id.
      Specified by:
      tag in interface ITagManager<T>
      Parameters:
      id - The id of the tag.
      Returns:
      A tag with the given id.
    • recalculate

      public void recalculate()
      Description copied from interface: ITagManager
      Recalculates the cached tag map.
      Specified by:
      recalculate in interface ITagManager<T>
    • tagMap

      public Map<net.minecraft.resources.ResourceLocation,KnownTag<T>> tagMap()
      Description copied from interface: ITagManager
      Gets a map of id to tag that this manager knows about.
      Specified by:
      tagMap in interface ITagManager<T>
      Returns:
      a map of id to tag.
    • internalTags

      public Map<net.minecraft.resources.ResourceLocation,Collection<net.minecraft.core.Holder<?>>> internalTags()
      Description copied from interface: ITagManager
      Gets the internal tags of this manager.
      Specified by:
      internalTags in interface ITagManager<T>
      Returns:
      a map of id to tag.
    • getInternal

      @Nullable public Collection<net.minecraft.core.Holder<T>> getInternal(KnownTag<T> tag)
    • getInternalRaw

      @Nullable public Collection<net.minecraft.core.Holder<?>> getInternalRaw(KnownTag<T> tag)
      Description copied from interface: ITagManager
      Gets the internal Collection<Holder> of the given tag.

      This method should only be used when you do not have access to the more specific version of this method in KnownTagManager

      Specified by:
      getInternalRaw in interface ITagManager<T>
      Parameters:
      tag - The tag to get the internal value of.
      Returns:
      The internal Collection<Holder> of the given tag.
    • tagKeys

      public List<net.minecraft.resources.ResourceLocation> tagKeys()
      Description copied from interface: ITagManager
      Gets the keys of the tags that this manager knows about.
      Specified by:
      tagKeys in interface ITagManager<T>
      Returns:
      A List of keys of the tags that this manager knows about.
    • addTag

      public <U> void addTag(net.minecraft.resources.ResourceLocation id, Collection<net.minecraft.core.Holder<U>> tag)
      Description copied from interface: ITagManager
      Adds a tag to this manager with the given id.
      Specified by:
      addTag in interface ITagManager<T>
      Parameters:
      id - The id of the tag to add.
      tag - The tag to add
    • bind

      public void bind(net.minecraft.tags.TagManager.LoadResult<?> result)
      Description copied from interface: ITagManager
      Binds this manager to the given load result.

      This is usually storing the given TagManager.LoadResult into a MutableLoadResult which allows for easy mutation.

      Specified by:
      bind in interface ITagManager<T>
      Parameters:
      result - The result to bind to.
    • getTagsFor

      public List<KnownTag<T>> getTagsFor(T element)