From ad28aad9a1f88ac4770d6efc3d5edf813eaac383 Mon Sep 17 00:00:00 2001 From: Gavin Lambert Date: Mon, 16 Sep 2024 01:06:28 +1200 Subject: [PATCH] Add biome tag audit (#10080) Adds biome tag audit, since they're interesting for food and structures. --- .../compatibility/CraftingTagAuditor.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/main/java/com/minecolonies/core/compatibility/CraftingTagAuditor.java b/src/main/java/com/minecolonies/core/compatibility/CraftingTagAuditor.java index 9b80d2623f9..c0ba8b82c71 100644 --- a/src/main/java/com/minecolonies/core/compatibility/CraftingTagAuditor.java +++ b/src/main/java/com/minecolonies/core/compatibility/CraftingTagAuditor.java @@ -17,12 +17,16 @@ import com.minecolonies.core.colony.buildings.modules.AnimalHerdingModule; import com.minecolonies.core.colony.buildings.modules.SimpleCraftingModule; import com.minecolonies.core.colony.crafting.*; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.food.FoodProperties; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.storage.LevelResource; import net.minecraftforge.registries.ForgeRegistries; @@ -60,6 +64,7 @@ public static void doRecipeAudit(@NotNull final MinecraftServer server, createFile("item tag audit", server, "tag_item_audit.csv", writer -> doItemTagAudit(writer, server)); createFile("block tag audit", server, "tag_block_audit.csv", writer -> doBlockTagAudit(writer, server)); createFile("path block audit", server, "path_block_audit.csv", writer -> doPathBlockTagAudit(writer, server)); + createFile("biome tag audit", server, "biome_tag_audit.csv", writer -> doBiomeTagAudit(writer, server)); createFile("recipe audit", server, "recipe_audit.csv", writer -> doRecipeAudit(writer, server, customRecipeManager)); createFile("domum audit", server, "domum_audit.csv", writer -> doDomumAudit(writer, server)); createFile("tools audit", server, "tools_audit.csv", writer -> doToolsAudit(writer, server)); @@ -203,6 +208,42 @@ private static void doPathBlockTagAudit(@NotNull final BufferedWriter writer, } } + private static void doBiomeTagAudit(@NotNull final BufferedWriter writer, + @NotNull final MinecraftServer server) throws IOException + { + writer.write("biome,name,tags..."); + writer.newLine(); + + final Registry biomes = server.registryAccess().registry(Registries.BIOME).orElse(null); + if (biomes == null) { return; } + + for (final ResourceLocation id : biomes.keySet().stream().sorted().toList()) + { + writer.write(id.toString()); + writer.write(','); + writer.write('"'); + writer.write(Component.translatable(id.toLanguageKey("biome")).getString().replace("\"", "\"\"")); + writer.write('"'); + biomes.getHolder(ResourceKey.create(biomes.key(), id)).ifPresent(holder -> + holder.tags() + .map(t -> t.location().toString()) + .sorted() + .forEach(t -> + { + try + { + writer.write(','); + writer.write(t); + } + catch (IOException e) + { + e.printStackTrace(); + } + })); + writer.newLine(); + } + } + private static void doRecipeAudit(@NotNull final BufferedWriter writer, @NotNull final MinecraftServer server, @NotNull final CustomRecipeManager customRecipeManager) throws IOException