Class TagSupplier.TagBakery

java.lang.Object
dev.lukebemish.dynamicassetgenerator.api.sources.TagSupplier.TagBakery
All Implemented Interfaces:
InputStreamSource, PathAwareInputStreamSource, Resettable, TagSupplier, Function<ResourceGenerationContext,Map<net.minecraft.resources.ResourceLocation,Set<net.minecraft.resources.ResourceLocation>>>
Enclosing interface:
TagSupplier

public static class TagSupplier.TagBakery extends Object implements PathAwareInputStreamSource, Resettable, TagSupplier
A utility for easily providing any number of tags to a resource cache.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface dev.lukebemish.dynamicassetgenerator.api.sources.TagSupplier

    TagSupplier.TagBakery
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Map<net.minecraft.resources.ResourceLocation,Set<net.minecraft.resources.ResourceLocation>>
     
    @Nullable String
    createCacheKey(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
    Create a key that can be uniquely used to identify the resource this generator will generate.
    @Nullable String
    createSupplierCacheKey(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
    Create a key that can be uniquely used to identify the tag map to be generated.
    net.minecraft.server.packs.resources.IoSupplier<InputStream>
    get(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
    Gets an input stream for the given resource location.
    @NonNull Set<net.minecraft.resources.ResourceLocation>
     
    void
    queue(TagSupplier tagSupplier)
    Queues an unresolved set of tags to be added when this source is resolved.
    void
    queue(Map<net.minecraft.resources.ResourceLocation,Set<net.minecraft.resources.ResourceLocation>> tags)
    Queues a set of tags to be added when this source is resolved.
    void
    queue(net.minecraft.resources.ResourceLocation tag, Set<net.minecraft.resources.ResourceLocation> entries)
    Queues the provided entries to be added to the provided tag when this source is resolved.
    void
    queue(net.minecraft.resources.ResourceLocation tag, net.minecraft.resources.ResourceLocation entry)
    Queues a single entry to be added to a tag when this source is resolved
    void
    Resets some state associated with sources registered to the resource cache.

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Constructor Details

    • TagBakery

      public TagBakery()
  • Method Details

    • queue

      public void queue(TagSupplier tagSupplier)
      Queues an unresolved set of tags to be added when this source is resolved.
      Parameters:
      tagSupplier - supplies a map of tag identifiers to sets of registry entry identifiers
    • queue

      public void queue(net.minecraft.resources.ResourceLocation tag, Set<net.minecraft.resources.ResourceLocation> entries)
      Queues the provided entries to be added to the provided tag when this source is resolved.
      Parameters:
      tag - the identifier of the tag to be queued
      entries - the identifiers of the registry entries to be added to the tag
    • queue

      public void queue(net.minecraft.resources.ResourceLocation tag, net.minecraft.resources.ResourceLocation entry)
      Queues a single entry to be added to a tag when this source is resolved
      Parameters:
      tag - the identifier of tag to add an entry to
      entry - the identifier of the entry to add
    • queue

      public void queue(Map<net.minecraft.resources.ResourceLocation,Set<net.minecraft.resources.ResourceLocation>> tags)
      Queues a set of tags to be added when this source is resolved.
      Parameters:
      tags - a map of tag identifiers to sets of registry entry identifiers
    • get

      public net.minecraft.server.packs.resources.IoSupplier<InputStream> get(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
      Description copied from interface: InputStreamSource
      Gets an input stream for the given resource location.
      Specified by:
      get in interface InputStreamSource
      Parameters:
      outRl - ResourceLocation to get the input stream for.
      context - ResourceGenerationContext containing information about when and where the resource is being generated.
      Returns:
      Supplier for an InputStream for the location. Should be null if the resource cannot be loaded.
    • getLocations

      public @NonNull Set<net.minecraft.resources.ResourceLocation> getLocations(ResourceGenerationContext context)
      Specified by:
      getLocations in interface PathAwareInputStreamSource
      Returns:
      the locations that this InputStreamSource can provide resources at.
    • reset

      public void reset(ResourceGenerationContext context)
      Description copied from interface: Resettable
      Resets some state associated with sources registered to the resource cache.
      Specified by:
      reset in interface Resettable
      Specified by:
      reset in interface TagSupplier
    • apply

      public Map<net.minecraft.resources.ResourceLocation,Set<net.minecraft.resources.ResourceLocation>> apply(ResourceGenerationContext context)
      Specified by:
      apply in interface Function<ResourceGenerationContext,Map<net.minecraft.resources.ResourceLocation,Set<net.minecraft.resources.ResourceLocation>>>
    • createCacheKey

      public @Nullable String createCacheKey(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
      Description copied from interface: InputStreamSource
      Create a key that can be uniquely used to identify the resource this generator will generate. Note that this is used for caching across reloads, and so should incorporate any resources that may be used to generate the resource. If this is not possible, return null.
      Specified by:
      createCacheKey in interface InputStreamSource
      Parameters:
      outRl - the resource location that will be generated
      context - the context that the resource will be generated in. Resources can safely be accessed in this context
      Returns:
      a key that can be used to uniquely identify the resource, or null if this is not possible
    • createSupplierCacheKey

      public @Nullable String createSupplierCacheKey(net.minecraft.resources.ResourceLocation outRl, ResourceGenerationContext context)
      Description copied from interface: TagSupplier
      Create a key that can be uniquely used to identify the tag map to be generated. Note that this is used for caching across reloads, and so should incorporate any resources that may be used to generate the resource. If this is not possible, return null.
      Specified by:
      createSupplierCacheKey in interface TagSupplier
      Parameters:
      outRl - the resource location that will be generated
      context - the context that the resource will be generated in. Resources can safely be accessed in this context
      Returns:
      a key that can be used to uniquely identify the resource, or null if this is not possible