Interface TagTemplate.Builder<T extends Taggable<T>>

All Superinterfaces:
AbstractBuilder<TagTemplate<T>>, Builder<TagTemplate<T>,TagTemplate.Builder<T>>, ResettableBuilder<TagTemplate<T>,TagTemplate.Builder<T>>, ResourceKeyedBuilder<TagTemplate<T>,TagTemplate.Builder<T>>
Enclosing interface:
TagTemplate<T extends Taggable<T>>

public static interface TagTemplate.Builder<T extends Taggable<T>> extends ResourceKeyedBuilder<TagTemplate<T>,TagTemplate.Builder<T>>
  • Method Details

    • replace

      TagTemplate.Builder<T> replace(boolean replace)
      Sets whether the values contained by a tag template will replace existing values if a tag with the same ResourceKeyed.key() and RegistryType already exists when datapacks are (re)loaded.

      If this is set to true, any previous entries for this given key-tag type combination will be discarded and the data in the built template will replace the data. If this is set to false, the entries in this template will be merged with any existing data. The default behavior is to merge data.

      As no guarantees are made to the order in which templates are applied when datapacks are (re)loaded, note that replacement will only act upon templates that have previously been applied.

      Parameters:
      replace - Whether to replace instead of merge.
      Returns:
      This builder, for chaining.
    • replace

      default TagTemplate.Builder<T> replace()
      Indicates that any existing values of a tag with the same ResourceKeyed.key() and RegistryType during datapack (re)loading will have their values discarded and replaced by this template.
      Returns:
      This builder, for chaining
      See Also:
    • addValue

      TagTemplate.Builder<T> addValue(RegistryKey<T> value, boolean required)
      Adds the RegistryKey for a value to the builder.

      As the objects that this tag will contain may be available at this stage, their resource key ID should be provided instead. However, this gives rise to the possibility that a value may not be available when tags are generated. The behavior during tag generation if the a value for the supplied key is not present can be controlled with the argument passed to the required parameter:

      • if true, the entire tag will not be applied.
      • if false, the tag will be applied without the value.
      Parameters:
      value - Value to add
      required - Whether this tag should fail to load if the value is not found while loading.
      Returns:
      This builder, for chaining
    • addValue

      default TagTemplate.Builder<T> addValue(RegistryKey<T> value)
      Adds the RegistryKey for a value to the builder, marking it as required.
      Parameters:
      value - Value to add
      Returns:
      This builder, for chaining
      See Also:
    • addValues

      TagTemplate.Builder<T> addValues(Collection<RegistryKey<T>> values, boolean required)
      Adds a collection of RegistryKeys for values to this builder.
      Parameters:
      values - Values to add
      required - Whether the values are required. If required, the tag will fail to load if they are not found while loading.
      Returns:
      This builder, for chaining.
      See Also:
    • addValues

      default TagTemplate.Builder<T> addValues(Collection<RegistryKey<T>> values)
      Adds a collection of RegistryKeys for values to this builder, marking all as required.
      Parameters:
      values - Values to add
      Returns:
      This builder, for chaining.
      See Also:
    • addChild

      TagTemplate.Builder<T> addChild(Tag<T> childTag, boolean required)
      Marks a tag with a given RegistryKey as a child of the tag generated by this template.

      A child Tag is considered a subset of its parent, that is, the tag generated from this template will include all values from all its children, as well as those directly provided via the addValue(s) methods.

      As Tags may not be available at this stage, their ResourceKeyed.key() should be provided instead. If the key does not point to a valid tag (or tag template) when datapacks are reloaded, the argument supplied to required determines whether this tag is ultimately generated, that is, if the supplied child key does not represent a tag:

      • if true, no tag will be generated.
      • if false, a tag will be generated without the given child.
      Parameters:
      childTag - RegistryKey for tag to be added.
      required - Whether loading this tag should fail if the child tag is not found.
      Returns:
      This builder, for chaining
    • addChild

      default TagTemplate.Builder<T> addChild(Tag<T> childTag)
      Marks a tag with a given RegistryKey as a required child of the tag generated by this template.
      Parameters:
      childTag - RegistryKey for tag to be added.
      Returns:
      This builder, for chaining
      See Also:
    • addChild

      Adds a child tag to this builder, using a TagTemplate.
      Parameters:
      childTag - The child to be added.
      Returns:
      This builder, for chaining
      Throws:
      IllegalArgumentException - If this TagTemplate is not the same RegistryType as this builder.
      See Also:
    • addChildren

      TagTemplate.Builder<T> addChildren(Collection<Tag<T>> children, boolean required)
      Adds multiple children to this template.
      Parameters:
      children - Children to add.
      required - Whether to fail loading the tag if these children are not found.
      Returns:
      This builder, for chaining
      See Also:
    • addChildren

      default TagTemplate.Builder<T> addChildren(Collection<Tag<T>> children)
      Adds multiple required children to this template.
      Parameters:
      children - Children to add.
      Returns:
      This builder, for chaining
      See Also:
    • addChildren

      TagTemplate.Builder<T> addChildren(Map<Tag<T>,Boolean> childrenMap)
      Adds multiple required children to this template, where each key-value pair in this map represents a child ResourceKey and whether the child is required.
      Parameters:
      childrenMap - Map of children, RegistryKey
      Returns:
      This builder, for chaining.
      See Also:
    • build

      @NonNull TagTemplate<T> build()
      Creates a TagTemplate that should be registered during the RegisterDataPackValueEvent.
      Specified by:
      build in interface AbstractBuilder<T extends Taggable<T>>
      Returns:
      The built TagTemplate.