2020-04-12 19:27:11 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2020-07-02 17:49:11 +00:00
|
|
|
* Copyright (c) 2016-2020.
|
2020-04-12 19:27:11 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2020-03-20 03:38:58 +00:00
|
|
|
package net.minecraftforge.common.extensions;
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
import net.minecraft.data.TagsProvider;
|
|
|
|
import net.minecraft.tags.ITag;
|
2020-06-25 01:25:55 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraftforge.common.ForgeHooks;
|
2020-03-20 03:38:58 +00:00
|
|
|
|
2020-06-25 01:25:55 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
//TODO, Tag removal support.
|
2020-03-20 03:38:58 +00:00
|
|
|
public interface IForgeTagBuilder<T>
|
|
|
|
{
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
default TagsProvider.Builder<T> getBuilder() {
|
|
|
|
return (TagsProvider.Builder<T>) this;
|
|
|
|
}
|
|
|
|
|
2020-06-29 19:42:26 +00:00
|
|
|
@SuppressWarnings("unchecked")
|
2020-06-19 14:58:45 +00:00
|
|
|
default TagsProvider.Builder<T> addTags(ITag.INamedTag<T>... values) {
|
|
|
|
TagsProvider.Builder<T> builder = getBuilder();
|
|
|
|
for (ITag.INamedTag<T> value : values) {
|
|
|
|
builder.func_240531_a_(value);
|
|
|
|
}
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
2020-06-25 01:25:55 +00:00
|
|
|
default TagsProvider.Builder<T> replace() {
|
|
|
|
return replace(true);
|
2020-03-20 03:38:58 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 01:25:55 +00:00
|
|
|
default TagsProvider.Builder<T> replace(boolean value) {
|
|
|
|
getBuilder().getInternalBuilder().replace(value);
|
|
|
|
return getBuilder();
|
2020-03-20 03:38:58 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 01:25:55 +00:00
|
|
|
default TagsProvider.Builder<T> addOptional(final ResourceLocation... locations)
|
2020-03-20 03:38:58 +00:00
|
|
|
{
|
2020-06-25 01:25:55 +00:00
|
|
|
return addOptional(Arrays.asList(locations));
|
2020-04-01 18:34:36 +00:00
|
|
|
}
|
2020-03-20 03:38:58 +00:00
|
|
|
|
2020-06-29 19:42:26 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2020-06-25 01:25:55 +00:00
|
|
|
default TagsProvider.Builder<T> addOptional(final Collection<ResourceLocation> locations)
|
2020-03-20 03:38:58 +00:00
|
|
|
{
|
2020-06-25 01:25:55 +00:00
|
|
|
return getBuilder().add(ForgeHooks.makeOptionalTag(true, locations));
|
2020-03-20 03:38:58 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 01:25:55 +00:00
|
|
|
default TagsProvider.Builder<T> addOptionalTag(final ResourceLocation... locations)
|
2020-03-20 03:38:58 +00:00
|
|
|
{
|
2020-06-25 01:25:55 +00:00
|
|
|
return addOptionalTag(Arrays.asList(locations));
|
2020-03-20 03:38:58 +00:00
|
|
|
}
|
|
|
|
|
2020-06-29 19:42:26 +00:00
|
|
|
@SuppressWarnings("deprecation")
|
2020-06-25 01:25:55 +00:00
|
|
|
default TagsProvider.Builder<T> addOptionalTag(final Collection<ResourceLocation> locations)
|
2020-03-20 03:38:58 +00:00
|
|
|
{
|
2020-06-25 01:25:55 +00:00
|
|
|
return getBuilder().add(ForgeHooks.makeOptionalTag(false, locations));
|
|
|
|
}
|
2020-03-20 03:38:58 +00:00
|
|
|
}
|