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
      • 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