From cb5f5a7412fb4d397fb4a81cc0f7caee9f1d5016 Mon Sep 17 00:00:00 2001 From: Juuz <6596629+Juuxel@users.noreply.github.com> Date: Fri, 6 Dec 2024 15:16:16 +0200 Subject: [PATCH] Move TagAliasGroup into the impl package --- .../impl/datagen/TagAliasGenerator.java | 2 +- .../fabric/api/tag/v1/TagAliasGroup.java | 75 ------------------- .../fabric/api/tag/v1/package-info.java | 32 +++++++- .../fabric/impl/tag/TagAliasGroup.java | 48 ++++++++++++ .../fabric/impl/tag/TagAliasLoader.java | 1 - 5 files changed, 80 insertions(+), 78 deletions(-) delete mode 100644 fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/TagAliasGroup.java create mode 100644 fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasGroup.java diff --git a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/TagAliasGenerator.java b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/TagAliasGenerator.java index 6d9ce45902..9e818b5773 100644 --- a/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/TagAliasGenerator.java +++ b/fabric-data-generation-api-v1/src/main/java/net/fabricmc/fabric/impl/datagen/TagAliasGenerator.java @@ -28,7 +28,7 @@ import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; -import net.fabricmc.fabric.api.tag.v1.TagAliasGroup; +import net.fabricmc.fabric.impl.tag.TagAliasGroup; public final class TagAliasGenerator { public static String getDirectory(RegistryKey> registryKey) { diff --git a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/TagAliasGroup.java b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/TagAliasGroup.java deleted file mode 100644 index 7a9c4edf6e..0000000000 --- a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/TagAliasGroup.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.fabricmc.fabric.api.tag.v1; - -import java.util.List; - -import com.mojang.serialization.Codec; - -import net.minecraft.registry.Registry; -import net.minecraft.registry.RegistryKey; -import net.minecraft.registry.tag.TagKey; - -/** - * A group of tags that refer to the same set of registry entries. - * The contained tags will be linked together and get the combined set of entries - * of all the aliased tags in a group. - * - *

Tag alias groups can be defined in data packs in the {@code data//fabric/tag_alias/} - * directory. {@code } is the path of the registry's ID, prefixed with {@code /} if it's - * not {@value net.minecraft.util.Identifier#DEFAULT_NAMESPACE}. - * - *

The JSON format of tag alias groups is an object with a {@code tags} list containing plain tag IDs. - * - *

If multiple tag alias groups include a tag, the groups will be combined and each tag will be an alias - * for the same contents. - * - *

Tag aliases in the {@code c} namespace

- * - *

For the names of shared {@code c} tag alias groups, it's important that you use a short and descriptive name. - * A good way to do this is reusing the name of a contained {@code c} tag that follows the naming conventions. - * For example, if the tag alias group contains the tags {@code c:flowers/tall} and {@code minecraft:tall_flowers}, - * the tag alias file should be named {@code flowers/tall.json}, like the contained {@code c} tag. - * - *

Tag alias groups in the {@code c} namespace are primarily intended for merging a {@code c} tag - * with an equivalent vanilla tag with no potentially unwanted gameplay behavior. If a vanilla tag affects - * game mechanics (such as the water tag affecting swimming), don't alias it as a {@code c} tag. - * - *

If you want to have the contents of a {@code c} tag in your own tag, prefer including the {@code c} tag - * in your tag file directly. That way, data packs can modify your tag separately. Tag aliases make their contained - * tags almost fully indistinguishable since they get the exact same content, and you have to override the alias group - * in a higher-priority data pack to unlink them. - * - * @param tags the tags in the group, must be from the same registry - * @param the type of registry entries in the tags - */ -public record TagAliasGroup(List> tags) { - /** - * Creates a codec for tag alias groups in the specified registry. - * - * @param registryKey the key of the registry where the tags are from - * @param the entry type - * @return the codec - */ - public static Codec> codec(RegistryKey> registryKey) { - return TagKey.unprefixedCodec(registryKey) - .listOf() - .fieldOf("tags") - .xmap(TagAliasGroup::new, TagAliasGroup::tags) - .codec(); - } -} diff --git a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/package-info.java b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/package-info.java index 22d56f5be4..1f5147f1d1 100644 --- a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/package-info.java +++ b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/api/tag/v1/package-info.java @@ -17,6 +17,36 @@ /** * The Fabric Tag API for working with {@linkplain net.minecraft.registry.tag.TagKey tags}. * - * @see net.fabricmc.fabric.api.tag.v1.TagAliasGroup + *

Aliasing tags

+ * Tag alias groups are lists of tags that refer to the same set of registry entries. + * The contained tags will be linked together and get the combined set of entries + * of all the aliased tags in a group. + * + *

Tag alias groups can be defined in data packs in the {@code data//fabric/tag_alias/} + * directory. {@code } is the path of the registry's ID, prefixed with {@code /} if it's + * not {@value net.minecraft.util.Identifier#DEFAULT_NAMESPACE}. For example, an alias group for block tags would be placed + * in {@code data//fabric/tag_alias/block/}. + * + *

The JSON format of tag alias groups is an object with a {@code tags} list. The list contains plain tag IDs with + * no {@code #} prefix. + * + *

If multiple tag alias groups include a tag, the groups will be combined and each tag will be an alias + * for the same contents. + * + *

Tag aliases in the {@code c} namespace

+ * + *

For the names of shared {@code c} tag alias groups, it's important that you use a short and descriptive name. + * A good way to do this is reusing the name of a contained {@code c} tag that follows the naming conventions. + * For example, if the tag alias group contains the tags {@code c:flowers/tall} and {@code minecraft:tall_flowers}, + * the tag alias file should be named {@code flowers/tall.json}, like the contained {@code c} tag. + * + *

Tag alias groups in the {@code c} namespace are primarily intended for merging a {@code c} tag + * with an equivalent vanilla tag with no potentially unwanted gameplay behavior. If a vanilla tag affects + * game mechanics (such as the water tag affecting swimming), don't alias it as a {@code c} tag. + * + *

If you want to have the contents of a {@code c} tag in your own tag, prefer including the {@code c} tag + * in your tag file directly. That way, data packs can modify your tag separately. Tag aliases make their contained + * tags almost fully indistinguishable since they get the exact same content, and you have to override the alias group + * in a higher-priority data pack to unlink them. */ package net.fabricmc.fabric.api.tag.v1; diff --git a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasGroup.java b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasGroup.java new file mode 100644 index 0000000000..494e7f779e --- /dev/null +++ b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasGroup.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016, 2017, 2018, 2019 FabricMC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.fabricmc.fabric.impl.tag; + +import java.util.List; + +import com.mojang.serialization.Codec; + +import net.minecraft.registry.Registry; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.tag.TagKey; + +/** + * A wrapper record for tag alias groups. + * + * @param tags the tags in the group, must be from the same registry + * @param the type of registry entries in the tags + */ +public record TagAliasGroup(List> tags) { + /** + * Creates a codec for tag alias groups in the specified registry. + * + * @param registryKey the key of the registry where the tags are from + * @param the entry type + * @return the codec + */ + public static Codec> codec(RegistryKey> registryKey) { + return TagKey.unprefixedCodec(registryKey) + .listOf() + .fieldOf("tags") + .xmap(TagAliasGroup::new, TagAliasGroup::tags) + .codec(); + } +} diff --git a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasLoader.java b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasLoader.java index d444daa8af..d26e8860c2 100644 --- a/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasLoader.java +++ b/fabric-tag-api-v1/src/main/java/net/fabricmc/fabric/impl/tag/TagAliasLoader.java @@ -50,7 +50,6 @@ import net.minecraft.util.profiler.Profiler; import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener; -import net.fabricmc.fabric.api.tag.v1.TagAliasGroup; public final class TagAliasLoader extends SinglePreparationResourceReloader>, List>> implements IdentifiableResourceReloadListener { public static final Identifier ID = Identifier.of("fabric-tag-api-v1", "tag_alias_groups");