[Changes] Sort Tags by name before writing

This commit is contained in:
Frank 2022-12-10 13:22:50 +01:00
parent f5e26e5e9c
commit cd65bcf4e8

View file

@ -8,6 +8,7 @@ import net.minecraft.resources.ResourceLocation;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.jetbrains.annotations.Nullable;
@ -51,6 +52,10 @@ public class TagDataProvider<T> extends FabricTagProvider<T> {
if (locs.isEmpty() && tags.isEmpty()) return;
final FabricTagProvider<T>.FabricTagBuilder builder = getOrCreateTagBuilder(tag);
locs.sort(Comparator.comparing(ResourceLocation::toString));
tags.sort(Comparator.comparing(a -> a.location().toString()));
locs.forEach(builder::add);
tags.forEach(builder::addTag);
}, (tag, loc) -> shouldAdd(tag.location()) || this.shouldAdd(loc));