Interface TagSet<T extends Keyed>

Type Parameters:
T - the Bukkit type of the elements
All Superinterfaces:
Keyed, Registerable<TagSet<T>>, Wrapper

@NullMarked @AsOf("3.1.0") public interface TagSet<T extends Keyed> extends Wrapper, Keyed, Registerable<TagSet<T>>
An abstraction over a set of registry entries that is either an explicit Set of elements or a reference to a named tag (ResourceKey). It mirrors Minecraft's HolderSet, which is likewise an inline list, or a tag. When this is a set of elements, this can be registered to a registry.
Since:
3.1.0
  • Method Details

    • register

      @AsOf("3.1.0") TagSet<T> register()
      Binds this tag set under its own key, which nothing else may have claimed.
      Specified by:
      register in interface Registerable<T extends Keyed>
      Returns:
      this tag set
      Throws:
      IllegalArgumentException - if a tag is already bound under this key; use append() to add to one instead
      Since:
      3.1.0
    • resourceKey

      @AsOf("3.1.0") Optional<ResourceKey> resourceKey()
      The key of the tag set.
      Returns:
      the tag set key
      Since:
      3.1.0
    • registryId

      @AsOf("3.1.0") RegistryId registryId()
      The registry the elements of this tag set resolve against.
      Returns:
      the registry discriminator
      Since:
      3.1.0
    • value

      @AsOf("3.1.0") Either<Set<T>,TagKey> value()
      The contents of this tag set: either an explicit set of elements, or a reference to a named tag.
      Returns:
      the set of values contained in this tag set
      Since:
      3.1.0
    • asHolderSet

      @AsOf("3.1.0") <U> U asHolderSet()
      If this is a holder set, returns the underlying set. If this is a tag key, returns the underlying set for that key.
      Type Parameters:
      U - the type of the underlying set
      Returns:
      the underlying set, if present
      Since:
      3.1.0
    • asTagKey

      @AsOf("3.1.0") <U> U asTagKey()
      If this is a tag key, returns the underlying tag key. If this is a holder set, tries to find a tag key which matches the items in this set, otherwise throws.
      Type Parameters:
      U - the type of the underlying tag key
      Returns:
      the underlying tag key, if present
      Throws:
      IllegalStateException - if this is a holder set, and no matching tag key can be found
      Since:
      3.1.0
    • append

      @AsOf("3.4.0") TagSet<T> append()
      Binds this tag set's elements into the tag already bound under its key, keeping everything that tag already held, and creating the tag if nothing is bound under that key yet.

      This is the additive counterpart to register(), which insists on a key nothing has claimed. Use it to add to a tag Minecraft or another plugin owns — putting a custom biome into minecraft:has_structure/village_plains so villages generate there, for instance.

      A tag the registry has handed out before is rebound in place, so whatever holds it already sees the new members straight away: a structure loaded from a data pack resolved its biome tag through the registry, so appending to that tag retargets the structure in a world that is already running, with nothing reloaded. A tag that exists only because Wyck created it, and that nothing has looked up, is replaced rather than rebound — re-read it after appending instead of holding the set across calls.

      Additive membership in a minecraft: tag is not an override: it only ever changes behavior where the elements it adds are present, so adding your own biomes to a vanilla biome tag cannot affect a world those biomes do not occur in.

      Returns:
      this tag set
      Throws:
      IllegalStateException - if this tag set has no resource key, or references a named tag instead of holding explicit elements
      Since:
      3.4.0
    • isBlockSet

      @AsOf("3.1.0") default boolean isBlockSet()
      Checks if this is a block tag set.
      Returns:
      true if this is a block tag set, false otherwise
      Since:
      3.1.0
    • isTag

      @AsOf("3.1.0") default boolean isTag()
      Checks if this is a tag set.
      Returns:
      true if this is a tag set, false otherwise
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(@Nullable ResourceKey resourceKey, Material... blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      resourceKey - the resource key of the tag set
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(@Nullable ResourceKey resourceKey, Set<Material> blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      resourceKey - the resource key of the tag set
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(Material... blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlocks

      @AsOf("3.1.0") static TagSet<Material> ofBlocks(Set<Material> blocks)
      Creates a tag set of explicit block materials.
      Parameters:
      blocks - the block materials
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlockTag

      @AsOf("3.1.0") static TagSet<Material> ofBlockTag(TagKey tag)
      Creates a tag set referencing a named block tag.
      Parameters:
      tag - the block tag key
      Returns:
      a new block tag set
      Since:
      3.1.0
    • ofBlockTag

      @AsOf("3.1.0") static TagSet<Material> ofBlockTag(ResourceKey key)
      Creates a key set referencing a named block key.
      Parameters:
      key - the block tag key
      Returns:
      a new block key set
      Since:
      3.1.0
    • ofBiomes

      @AsOf("3.4.0") static TagSet<Biome> ofBiomes(@Nullable ResourceKey resourceKey, Biome... biomes)
      Creates a tag set of explicit biomes.
      Parameters:
      resourceKey - the resource key of the tag set
      biomes - the biomes
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • ofBiomes

      @AsOf("3.4.0") static TagSet<Biome> ofBiomes(@Nullable ResourceKey resourceKey, Set<Biome> biomes)
      Creates a tag set of explicit biomes.
      Parameters:
      resourceKey - the resource key of the tag set
      biomes - the biomes
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • ofBiomes

      @AsOf("3.4.0") static TagSet<Biome> ofBiomes(Set<Biome> biomes)
      Creates a tag set of explicit biomes.
      Parameters:
      biomes - the biomes
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • ofBiomes

      @AsOf("3.4.0") static TagSet<Biome> ofBiomes(Biome... biomes)
      Creates a tag set of explicit biomes.
      Parameters:
      biomes - the biomes
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • ofBiomeTag

      @AsOf("3.4.0") static TagSet<Biome> ofBiomeTag(TagKey tag)
      Creates a tag set referencing a named biome tag.
      Parameters:
      tag - the biome tag key
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • ofBiomeTag

      @AsOf("3.4.0") static TagSet<Biome> ofBiomeTag(ResourceKey key)
      Creates a tag set referencing a named biome tag.
      Parameters:
      key - the biome tag identifier
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • ofTag

      @AsOf("3.1.0") static <T extends Keyed> TagSet<T> ofTag(TagKey tag)
      Creates a tag set referencing the given named tag.
      Type Parameters:
      T - the Bukkit type of the elements
      Parameters:
      tag - the tag key
      Returns:
      a new tag set
      Since:
      3.1.0
    • blocks

      @AsOf("3.1.0") static TagSet<Material> blocks(Either<Set<Material>, TagKey> value)
      Creates a block tag set from an Either of explicit materials or a named tag.
      Parameters:
      value - either the explicit block materials, or a named block tag
      Returns:
      a new block tag set
      Since:
      3.1.0
    • timelines

      @AsOf("3.2.0") static TagSet<Timeline> timelines(Either<Set<Timeline>, TagKey> value)
      Creates a tag set from an Either of explicit tags or a named tag.
      Parameters:
      value - either the explicit timelines, or a named timeline tag
      Returns:
      a new tag set
      Since:
      3.2.0
    • biomes

      @AsOf("3.4.0") static TagSet<Biome> biomes(Either<Set<Biome>, TagKey> value)
      Creates a biome tag set from an Either of explicit biomes or a named tag.
      Parameters:
      value - either the explicit biomes, or a named biome tag
      Returns:
      a new biome tag set
      Since:
      3.4.0
    • of

      @Internal static <T extends Keyed> TagSet<T> of(@Nullable ResourceKey resourceKey, RegistryId registry, Set<T> elements)
    • of

      @Internal static <T extends Keyed> TagSet<T> of(@Nullable ResourceKey resourceKey, RegistryId registry, Either<Set<T>,TagKey> value)
    • decodeBlocks

      @AsOf("3.3.0") static TagSet<Material> decodeBlocks(Object minecraftHolderSet)
      Reads a Minecraft block holder set, preserving a named tag when present.
      Parameters:
      minecraftHolderSet - the Minecraft block holder set
      Returns:
      the decoded block tag set
      Since:
      3.3.0
    • decodeBiomes

      @AsOf("3.4.0") static TagSet<Biome> decodeBiomes(Object minecraftHolderSet)
      Reads a Minecraft biome holder set, preserving a named tag when present.
      Parameters:
      minecraftHolderSet - the Minecraft biome holder set
      Returns:
      the decoded biome tag set
      Since:
      3.4.0
    • toBuilder

      @AsOf("3.1.0") default TagSet.Builder<T> toBuilder()
      Creates a new builder from this tag set.
      Returns:
      a new builder
      Since:
      3.1.0
    • builder

      @AsOf("3.1.0") static <T extends Keyed> TagSet.Builder<T> builder()
      Creates a new builder.
      Type Parameters:
      T - the Bukkit type of the elements
      Returns:
      a new builder
      Since:
      3.1.0
    • blocks

      @AsOf("3.1.0") static TagSet.Builder<Material> blocks()
      Creates a new builder for block tag sets.
      Returns:
      a new builder
      Since:
      3.1.0
    • timelines

      @AsOf("3.2.0") static TagSet.Builder<Timeline> timelines()
      Creates a new builder for timeline tag sets.
      Returns:
      a new builder
      Since:
      3.2.0
    • biomes

      @AsOf("3.4.0") static TagSet.Builder<Biome> biomes()
      Creates a new builder for biome tag sets.
      Returns:
      a new builder
      Since:
      3.4.0