Posted October 31, 20205 yr I'm trying to register a Biome with a Feature from my mod, but I'm having difficulty because Biome registration happens before Feature registration. This is the relevant registration code: Feature (DeferredRegister) Biome (DeferredRegister) ConfiguredFeature (Vanilla registry, called from here in RegistryEvent.Register<Biome> with HIGH priority to run before Biome DeferredRegister). The game crashes on startup because the ConfiguredFeature registration runs before the Feature has been registered: java.lang.NullPointerException: Registry Object not present: testmod3:banner at java.util.Objects.requireNonNull(Objects.java:290) at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) at choonster.testmod3.init.ModConfiguredFeatures.register(ModConfiguredFeatures.java:25) at choonster.testmod3.TestMod3.registerBiomes(TestMod3.java:57) What's the best way to work around this? Should I create the Features in RegistryEvent.Register<Biome> and then register them in RegistryEvent.Register<Feature>? Edited November 1, 20205 yr by Choonster Solved Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
November 1, 20205 yr If I'm not mistaken, there should be a builder that allows a supplier of a configured feature to be taken in. However, if this does not work, then you would need to handle the features within the biome itself in the highest priority. You can also create a json version of the biome and use the entry as a dummy. This way the feature can be loaded into the world from the json itself without the need to navigate around registries. Edited November 1, 20205 yr by ChampionAsh5357
November 1, 20205 yr Author 3 hours ago, ChampionAsh5357 said: If I'm not mistaken, there should be a builder that allows a supplier of a configured feature to be taken in. However, if this does not work, then you would need to handle the features within the biome itself in the highest priority. You can also create a json version of the biome and use the entry as a dummy. This way the feature can be loaded into the world from the json itself without the need to navigate around registries. Thanks, I saw the Supplier overloads but didn't think to use them for lazy/deferred references. I realised after posting that my issue was actually with a SurfaceBuilder rather than a Feature (I could have moved the Feature registration since it wasn't being used in the Biome), but the same solution applies: use the Supplier overload instead of trying to pass the ConfiguredSurfaceBuilder directly. For future reference, I fixed the original issue and a few related worldgen registration issues with this commit. I decided not to go with the JSON route since my biome makes use of a lot of Vanilla features/structures (the same ones as the Vanilla Desert biome) and I didn't want to write all of that out by hand. I would have liked a data generator approach like blockstates, models, loot tables, etc.; but the Vanilla BiomeProvider is only designed to generate "report" files from already-registered Biomes. I did end up adding my own version of BiomeProvider that only generates files for my own mod's biomes in this commit, the generated JSON file is 1,968 lines. Edited November 1, 20205 yr by Choonster Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
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.