From 722343c103bc295011eea19024a3e30a7131f4e6 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 8 Jun 2022 20:33:54 +0200 Subject: [PATCH] [Fix] Empty Tags are not created. This also invalidates other dependant tags --- .../bclib/api/v2/tag/CommonBlockTags.java | 9 +++++---- .../org/betterx/bclib/api/v2/tag/TagType.java | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/betterx/bclib/api/v2/tag/CommonBlockTags.java b/src/main/java/org/betterx/bclib/api/v2/tag/CommonBlockTags.java index bf1828b7..d8bfe4b8 100644 --- a/src/main/java/org/betterx/bclib/api/v2/tag/CommonBlockTags.java +++ b/src/main/java/org/betterx/bclib/api/v2/tag/CommonBlockTags.java @@ -48,6 +48,11 @@ public class CommonBlockTags { TagAPI.BLOCKS.add(SOUL_GROUND, Blocks.SOUL_SAND, Blocks.SOUL_SOIL); TagAPI.BLOCKS.add(IS_OBSIDIAN, Blocks.OBSIDIAN, Blocks.CRYING_OBSIDIAN); + + TagAPI.BLOCKS.add(MYCELIUM, Blocks.MYCELIUM); + TagAPI.BLOCKS.addOtherTags(MYCELIUM, NETHER_MYCELIUM); + + TagAPI.BLOCKS.add(TERRAIN, Blocks.MAGMA_BLOCK, Blocks.GRAVEL, @@ -57,7 +62,6 @@ public class CommonBlockTags { Blocks.BONE_BLOCK, Blocks.SCULK ); - TagAPI.BLOCKS.addOtherTags(TERRAIN, BlockTags.DRIPSTONE_REPLACEABLE, BlockTags.BASE_STONE_OVERWORLD, @@ -68,8 +72,5 @@ public class CommonBlockTags { NETHER_MYCELIUM, MYCELIUM, END_STONES); - - TagAPI.BLOCKS.add(MYCELIUM, Blocks.MYCELIUM); - TagAPI.BLOCKS.addOtherTags(MYCELIUM, NETHER_MYCELIUM); } } diff --git a/src/main/java/org/betterx/bclib/api/v2/tag/TagType.java b/src/main/java/org/betterx/bclib/api/v2/tag/TagType.java index 6ad2fc14..1132833a 100644 --- a/src/main/java/org/betterx/bclib/api/v2/tag/TagType.java +++ b/src/main/java/org/betterx/bclib/api/v2/tag/TagType.java @@ -46,6 +46,7 @@ public class TagType { @Override public TagKey makeTag(ResourceLocation id) { + initializeTag(id); return registry .getTagNames() .filter(tagKey -> tagKey.location().equals(id)) @@ -102,6 +103,10 @@ public class TagType { this.locationProvider = locationProvider; } + protected void initializeTag(ResourceLocation tagID){ + getSetForTag(tagID); + } + public Set getSetForTag(ResourceLocation tagID) { return tags.computeIfAbsent(tagID, k -> Sets.newHashSet()); } @@ -121,6 +126,11 @@ public class TagType { * @return the corresponding TagKey {@link TagKey}. */ public TagKey makeTag(ResourceLocation id) { + return creatTagKey(id); + } + + protected TagKey creatTagKey(ResourceLocation id) { + initializeTag(id); return TagKey.create(registryKey, id); } @@ -132,7 +142,7 @@ public class TagType { * @see Fabric Wiki (Tags) */ public TagKey makeCommonTag(String name) { - return TagKey.create(registryKey, new ResourceLocation("c", name)); + return creatTagKey(new ResourceLocation("c", name)); } public void addUntyped(TagKey tagID, ResourceLocation... elements) { @@ -212,10 +222,11 @@ public class TagType { if (Registry.BIOME_REGISTRY.equals(registryKey)) InternalBiomeAPI._runBiomeTagAdders(); //this.isFrozen = true; - this.forEach((id, ids) -> apply(tagsMap.computeIfAbsent(id, key -> Lists.newArrayList()), ids)); + this.forEach((id, ids) -> apply(id, tagsMap.computeIfAbsent(id, key -> Lists.newArrayList()), ids)); } - private static List apply(List builder, + private static List apply(ResourceLocation id, + List builder, Set ids) { ids.forEach(value -> builder.add(new TagLoader.EntryWithSource(value, BCLib.MOD_ID))); return builder;