Posted March 31, 20232 yr Hello - I'm having some issues with retrieving and operating on data in a Stream of biome tags and not sure if my issue is with my dated knowledge of Java or my usage of Forge code - so I would appreciate some help. I'm running this method - the stuff inside doesn't really matter here, because nothing inside this method is ever run. I've added print statements to debug and they are never executed. .getTagNames() should return a stream of biome keys which are then operated on. AmbienceMod.biomekeys.getTagNames().forEach(t -> { if (world.getBiomeManager().getBiome(pos).is(t)) { if (primaryTagMap.containsKey(t.location()) ) { biomereturn = t.location(); secondaryreturn = false; } if (secondaryTagMap.containsKey(t.location()) ) { biomereturn = t.location(); secondaryreturn = true; } }}); } And this is my definition of "biomekeys": static @Nullable ITagManager<Biome> biomekeys; <irrelevant code here> biomekeys = ForgeRegistries.BIOMES.tags(); This could be something really trivial I've missed but it's had me scratching my head for a while now. Edited March 31, 20232 yr by SpectralGerbil
March 31, 20232 yr I already showed you how to get the biomes loaded from datapacks by using the server's RegistryAccess. Look at this code: @EventBusSubscriber(modid = MODID) public class Test { @SubscribeEvent public static void listBiomes(ServerStartingEvent event) { var biomes = event.getServer().registryAccess().registryOrThrow(Registries.BIOME); LOG.info("Datapack: " + biomes.stream().toList().size()); LOG.info("Forge: " + ForgeRegistries.BIOMES.getValues().size()); } } Which when run against 1.19.4 produces: Datapack: 63 Forge: 0 I don't know why that Forge Biome registry still exists? All the other dynamic registries were removed when Mojang changed how datapack registries work in 1.19.3 https://gist.github.com/ChampionAsh5357/c21724bafbc630da2ed8899fe0c1d226#registries Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
March 31, 20232 yr Author Ohh, thank you! I wasn't fully aware that they needed to be fetched at startup - thanks for the help!
March 31, 20232 yr Author Ok, so to elaborate - I'm currently on 1.19.2, not 1.19.4 - so "Registries" doesn't exist - going backwards off the link you sent, it seems BuiltInRegistries should work, but that doesn't work with RegistryorThrow or any similar methods I'm aware of within registry access. That's also why the old Forge registry still existed. Any idea how to do this for 1.19.2?
March 31, 20232 yr All the ResourceKeys where defined in the Registry inteface class before Mojang's refactoring. I think it was Registry.BIOME_REGISTRY Edited March 31, 20232 yr by warjort Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
March 31, 20232 yr Author So something like this should work for getting the biome tags, saving them, and then checking them against a biome and map? //In main class: //(Just to be sure, does ServerStartingEvent fire on the client or do I need something else? - this mod is client only) static List<TagKey<Biome>> biomes = null; static Registry<Biome> biomeregistry = null; @SubscribeEvent public static void listBiomes(ServerStartingEvent event) { biomeregistry = event.getServer().registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); biomes = biomeregistry.getTagNames().toList(); } //And then retrieve in another class: Main.biomes.forEach(t -> { if (world.getBiomeManager().getBiome(pos).is(t)) { if (primaryTagMap.containsKey(t.location()) ) { biomereturn = t.location(); secondaryreturn = false; } if (secondaryTagMap.containsKey(t.location()) ) { biomereturn = t.location(); secondaryreturn = true; } }});
March 31, 20232 yr Author Got it working - thanks for the brilliant help!! Will post here how I did it in case others need the same information: //In main class: static List<TagKey<Biome>> biomes = null; static Registry<Biome> biomeregistry = null; @SubscribeEvent public void listBiomes(TagsUpdatedEvent event) { biomeregistry = event.getRegistryAccess().registryOrThrow(Registry.BIOME_REGISTRY); biomes = biomeregistry.getTagNames().toList(); } //In retrieving class: if (Main.biomes != null) { Main.biomes.forEach(t -> { if (world.getBiomeManager().getBiome(pos).is(t)) { if (primaryTagMap.containsKey(t.location()) ) { biomereturn = t.location(); secondaryreturn = false; } if (secondaryTagMap.containsKey(t.location()) ) { biomereturn = t.location(); secondaryreturn = true; } }}); }
March 31, 20232 yr You shouldn't be caching the registry like that. You should just retrieve the data when you need it. At best you will have the wrong registry if somebody reloads the datapacks. At worst you will cause memory leaks or weird bugs. Caching data in static fields is a major cause of memory leaks in java and/or data leaking into contexts where it is not valid. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.