Class KnownTagManager<T>

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

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

    Constructors
    Constructor
    Description
    KnownTagManager(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> resourceKey, Class<T> elementClass)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    addElements(KnownTag<T> to, T... values)
     
    void
    addId(KnownTag<T> to, net.minecraft.resources.ResourceLocation... values)
    Adds the elements that correspond to the given ResourceLocation to the given tag.
    <U> void
    addTag(net.minecraft.resources.ResourceLocation id, net.minecraft.tags.Tag<net.minecraft.core.Holder<U>> tag)
    Adds a tag to this manager with the given id.
    void
    bind(net.minecraft.tags.TagManager.LoadResult<?> result)
    Binds this manager to the given load result.
    void
    clear(KnownTag<T> from)
    Clears all values of the given tag.
    Gets the element type that this tag manager handles.
    Gets the elements of the given tag.
    net.minecraft.tags.Tag<net.minecraft.core.Holder<T>>
     
    net.minecraft.tags.Tag<net.minecraft.core.Holder<?>>
    Gets the internal Tag<Holder> of the given tag.
    getTagsFor(T element)
     
    Map<net.minecraft.resources.ResourceLocation,net.minecraft.tags.Tag<net.minecraft.core.Holder<?>>>
    Gets the internal tags of this manager.
    void
    Recalculates the cached tag map.
    final void
    removeElements(KnownTag<T> from, T... values)
     
    final void
    removeId(KnownTag<T> from, net.minecraft.resources.ResourceLocation... values)
    Removes the elements that correspond to the given ResourceLocation from the given tag.
    net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>>
    Gets the resource key of the registry that this manager deals with.
    tag(String id)
    Gets a tag with the given id.
    tag(net.minecraft.resources.ResourceLocation id)
    Gets a tag with the given id.
    List<net.minecraft.resources.ResourceLocation>
    Gets the keys of the tags that this manager knows about.
    Map<net.minecraft.resources.ResourceLocation,KnownTag<T>>
    Gets a map of id to tag that this manager knows about.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.blamejared.crafttweaker.api.tag.manager.ITagManager

    exists, exists, exists, getCommandString, getTagsFor, idElements, iterator, tag, tagFolder, tags

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • 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,net.minecraft.tags.Tag<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 net.minecraft.tags.Tag<net.minecraft.core.Holder<T>> getInternal(KnownTag<T> tag)
    • getInternalRaw

      @Nullable public net.minecraft.tags.Tag<net.minecraft.core.Holder<?>> getInternalRaw(KnownTag<T> tag)
      Description copied from interface: ITagManager
      Gets the internal Tag<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 Tag<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, net.minecraft.tags.Tag<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)