Fixes for Tag DataGen

This commit is contained in:
Frank 2022-12-04 22:13:06 +01:00
parent 2fa5c9510a
commit 0308437eaa
3 changed files with 20 additions and 15 deletions

View file

@ -24,6 +24,7 @@ import com.google.common.collect.Sets;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.Function;
public class TagRegistry<T> {
@ -264,16 +265,25 @@ public class TagRegistry<T> {
}
public void forEachTag(TriConsumer<TagKey<T>, List<ResourceLocation>, List<TagKey<T>>> consumer) {
forEachTag(consumer, null);
}
public void forEachTag(
TriConsumer<TagKey<T>, List<ResourceLocation>, List<TagKey<T>>> consumer,
BiPredicate<TagKey<T>, ResourceLocation> allow
) {
tags.forEach((tag, set) -> {
List<ResourceLocation> locations = new LinkedList<>();
List<TagKey<T>> tags = new LinkedList<>();
set.forEach(e -> {
ExtraCodecs.TagOrElementLocation t = e.elementOrTag();
if (t.tag()) {
tags.add(TagKey.create(registryKey, t.id()));
} else {
locations.add(t.id());
if (allow == null || allow.test(tag, t.id())) {
if (t.tag()) {
tags.add(TagKey.create(registryKey, t.id()));
} else {
locations.add(t.id());
}
}
});