Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add vararg helper methods for multi-tag support in the FabricTagBuilder #4452

Merged
merged 7 commits into from
Feb 20, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,17 @@ public FabricTagBuilder addTag(TagKey<T> tag) {
return this;
}

/**
* Add multiple tags to this tag.
*
* @return the {@link FabricTagBuilder} instance
*/
@SafeVarargs
public final FabricTagBuilder addTags(TagKey<T>... tags) {
Stream.of(tags).forEach(this::addTag);
return this;
}

/**
* Add another optional tag to this tag.
*
Expand All @@ -392,11 +403,22 @@ public FabricTagBuilder addOptionalTag(TagKey<T> tag) {
return addOptionalTag(tag.id());
}

/**
* Add multiple optional tags to this tag.
*
* @return the {@link FabricTagBuilder} instance
*/
@SafeVarargs
public final FabricTagBuilder addOptionalTags(TagKey<T>... tags) {
Stream.of(tags).forEach(this::addOptionalTag);
return this;
}

/**
* Add another tag to this tag, ignoring any warning.
*
* <p><b>Note:</b> only use this method if you sure that the tag will be always available at runtime.
* If not, use {@link #addOptionalTag(Identifier)} instead.
* If not, use {@link #addOptionalTag(TagKey)} instead.
*
* @return the {@link FabricTagBuilder} instance
*/
Expand All @@ -405,6 +427,20 @@ public FabricTagBuilder forceAddTag(TagKey<T> tag) {
return this;
}

/**
* Add multiple tags to this tag, ignoring any warning.
*
* <p><b>Note:</b> only use this method if you sure that the tags will be always available at runtime.
* If not, use {@link #addOptionalTags(TagKey[])} instead.
*
* @return the {@link FabricTagBuilder} instance
*/
@SafeVarargs
public final FabricTagBuilder forceAddTags(TagKey<T>... tags) {
Stream.of(tags).forEach(this::forceAddTag);
return this;
}

/**
* Add multiple elements to this tag.
*
Expand Down