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

    • Method Detail

      • 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 TagType 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.
      • 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
      • addValues

        TagTemplate.Builder<T> addValues​(java.util.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:
        addValue(RegistryKey, boolean)
      • addChild

        TagTemplate.Builder<T> addChild​(RegistryKey<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

        TagTemplate.Builder<T> addChild​(TagTemplate childTag)
                                 throws java.lang.IllegalArgumentException
        Adds a child tag to this builder, using a TagTemplate.
        Parameters:
        childTag - The child to be added.
        Returns:
        This builder, for chaining
        Throws:
        java.lang.IllegalArgumentException - If this TagTemplate is not the same TagType as this builder.
        See Also:
        addChild(RegistryKey, boolean)
      • addChildren

        TagTemplate.Builder<T> addChildren​(java.util.Collection<RegistryKey<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:
        addChild(RegistryKey, boolean)
      • addChildren

        TagTemplate.Builder<T> addChildren​(java.util.Map<RegistryKey<Tag<T>>,​java.lang.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:
        addChild(RegistryKey, boolean)