Fixes for Tag DataGen
This commit is contained in:
parent
2fa5c9510a
commit
0308437eaa
3 changed files with 20 additions and 15 deletions
|
@ -48,16 +48,11 @@ public class TagDataProvider<T> extends FabricTagProvider<T> {
|
|||
@Override
|
||||
protected void addTags(HolderLookup.Provider arg) {
|
||||
tagRegistry.forEachTag((tag, locs, tags) -> {
|
||||
if (locs.isEmpty() && tags.isEmpty()) return;
|
||||
|
||||
final FabricTagProvider<T>.FabricTagBuilder builder = getOrCreateTagBuilder(tag);
|
||||
|
||||
boolean modTag = shouldAdd(tag.location());
|
||||
locs.stream()
|
||||
.filter(loc -> modTag || this.shouldAdd(loc))
|
||||
.forEach(builder::add);
|
||||
|
||||
tags.stream()
|
||||
.filter(tagKey -> modTag || this.shouldAdd(tagKey.location()))
|
||||
.forEach(builder::addTag);
|
||||
});
|
||||
locs.forEach(builder::add);
|
||||
tags.forEach(builder::addTag);
|
||||
}, (tag, loc) -> shouldAdd(tag.location()) || this.shouldAdd(loc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class TestBiomes extends TagDataProvider<Biome> {
|
|||
FabricDataOutput output,
|
||||
CompletableFuture<HolderLookup.Provider> registriesFuture
|
||||
) {
|
||||
super(TagManager.BIOMES, List.of(BCLib.MOD_ID, WorldsTogether.MOD_ID), output, registriesFuture);
|
||||
super(TagManager.BIOMES, List.of(BCLib.MOD_ID, WorldsTogether.MOD_ID, "c"), output, registriesFuture);
|
||||
}
|
||||
|
||||
public static void bootstrap(BootstapContext<Biome> bootstrapContext) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue