Posted December 24, 20204 yr I am adding natural Amethyst Ore generation to the world. I am receiving the loading error: [ne.mi.fm.ja.FMLModContainer/LOADING]: Failed to register automatic subscribers. ModID: magiksmostevile, class genelectrovise.magiksmostevile.common.core.MagiksMostEvile java.lang.IllegalArgumentException: Method public static void genelectrovise.magiksmostevile.common.world.gen.ore.OreFeatureRegistry.addOresToBiomes(net.minecraftforge.event.world.BiomeLoadingEvent) has @SubscribeEvent annotation, but takes an argument that is not a subtype of the base type interface net.minecraftforge.fml.event.lifecycle.IModBusEvent: class net.minecraftforge.event.world.BiomeLoadingEvent ... which is fairly obvious from looking through the heirarchy. All of these posts say to use BiomeLoadingEvent to register features: https://forums.minecraftforge.net/topic/92868-1163-biomeloadingevent/ https://forums.minecraftforge.net/topic/94945-1164how-to-generate-ores/ https://forums.minecraftforge.net/topic/90560-1162-how-to-add-custom-ore-to-world-generation/ https://forums.minecraftforge.net/topic/91702-1163-add-custom-generation/ ... but FML doesn't like me doing this. Should I be using another Event? Am I using this one correcly? My subscribed methods: /** * Form the lists of ores to register * * @param event */ @SubscribeEvent public static void createOreLists(final FMLCommonSetupEvent event) { overworldOres(); netherOres(); endOres(); } /** * Trigger ore registration. * * @param event */ @SubscribeEvent(priority = EventPriority.HIGH) public static void addOresToBiomes(final BiomeLoadingEvent event) { registerOres(event); } private static void overworldOres() { overworldOres .add(new SimpleConfiguredOreFeature.Builder().withSimpleOreFeature(new SimpleOreFeature()) .withSimpleOreFeatureConfiguration( new SimpleOreFeatureConfiguration(Blocks.STONE.getDefaultState(), EvileDeferredRegistry.AMETHYST_ORE_OVERWORLD.get().getDefaultState(), 10, true)) .build()); } Where I subscribe them: public MagiksMostEvile() { LOGGER.info("Magiks Most Evile is being loaded by FML"); EVENT_BUS = FMLJavaModLoadingContext.get().getModEventBus(); registerCommonEvents(); EvileDeferredRegistry.init(FMLJavaModLoadingContext.get().getModEventBus()); } public static void registerCommonEvents() { LOGGER.debug("Registering MME common events"); EVENT_BUS.register(OreFeatureRegistry.class); } The active branch of my GitHub repository: https://github.com/GenElectrovise/MagiksMostEvile/tree/feature/1.16.4/update_to_1.16.4/src/main/java/genelectrovise/magiksmostevile/common/world/gen Thanks! Edited December 26, 20204 yr by GenElectrovise Submitted too early How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
December 24, 20204 yr Events for your mod are fired on two main buses, the mod bus and the forge bus. BiomeLoadingEvent is fired in the latter. Make sure you are subscribing your event handler to the correct event bus Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
December 24, 20204 yr Author Thanks @Beethoven92: I tried only using @Mod.EventBusSubscriber(modid = MagiksMostEvile.MODID, bus = Bus.FORGE), and combining the two methods into one call: /** * Called on {@link Bus.Forge}. Trigger ore registration. * * @param event */ @SubscribeEvent(priority = EventPriority.HIGH) public static void addOresToBiomes(final BiomeLoadingEvent event) { MagiksMostEvile.LOGGER.debug("Adding MME ores: Biome=" + event.getName()); createOreLists(); registerOres(event); } /** * Form the lists of ores to register * * @param event */ public static void createOreLists() { MagiksMostEvile.LOGGER.debug("Creating ore lists for MME feature addition!"); overworldOres(); netherOres(); endOres(); } (Result: Auto-subscribing genelectrovise.magiksmostevile.common.world.gen.ore.OreFeatureRegistry to FORGE) Two things: 1) This doesn't seem like the right way to handle this, though? Registering the features should not be done every time a biome is loaded - that seems wrong to me. 2) Whenever I try to join a world with that code active, I get this very odd error: [12:11:46] [Server thread/DEBUG] [ne.mi.fm.ne.FMLHandshakeHandler/FMLHANDSHAKE]: Handshake complete! [12:11:46] [Netty Local Client IO #0/INFO] [ne.mi.fm.ne.NetworkHooks/]: Connected to a modded server. [12:11:46] [Server thread/INFO] [ne.mi.co.AdvancementLoadFix/]: Using new advancement loading for net.minecraft.advancements.PlayerAdvancements@55ab5742 [12:11:46] [Server thread/INFO] [minecraft/PlayerList]: Dev[local:E:26a17569] logged in with entity id 257 at (-20.12474734205128, 72.0, 90.2353098908319) [12:11:46] [Server thread/INFO] [minecraft/MinecraftServer]: Dev joined the game [12:11:46] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Dev lost connection: Internal Exception: java.lang.ClassCastException: net.minecraft.network.login.ServerLoginNetHandler cannot be cast to net.minecraft.client.network.play.IClientPlayNetHandler [12:11:46] [Server thread/INFO] [minecraft/MinecraftServer]: Dev left the game [12:11:46] [Server thread/INFO] [minecraft/ServerPlayNetHandler]: Stopping singleplayer server as player logged out [12:11:46] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server Could this be a result of (1)? Maybe some strange de-sync issue? How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
December 24, 20204 yr Author I've made some additions - what stages should everything be occurring at? If I should use BiomeLoadingEvent to add features to a biome, which event should I be using to make and register the features themselves? Is there a way to do this with DeferredRegister? How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
December 25, 20204 yr You can register features like you did it before, not sure where you are having troubles. Show the code you tried so far please Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port
December 26, 20204 yr Author I've resolved the error: It was resulting from a NullPointerException while I was adding my features to biomes, which was concealed behind a resulting exception which was traced back to the mouseClickEventHandler which was triggered when I loaded the world. I was adding my features to a static ConfiguredFeature<?,?> [ ], before they were actually loaded, with the expectation that the array references would be updated as well, but I guess concurrency decided that wouldn't happen. Now the final call of my event handler populates the arrays and everything works fine. My new code is: OreFeaures.java public static ConfiguredFeature<?, ?>[] OVERWORLD_ORES; public static ConfiguredFeature<?, ?>[] NETHER_ORES; public static ConfiguredFeature<?, ?>[] END_ORES; @SubscribeEvent //Subbed to MOD public static void createConfiguredOreFeatures(FMLCommonSetupEvent event) { MagiksMostEvile.LOGGER.debug("Creating MME configured ore features"); // Amethyst Ore Overworld AMETHYST_ORE_OVERWORLD = Registry.register( // WorldGenRegistries.CONFIGURED_FEATURE, // "amethyst_ore_overworld_generation", // Feature.ORE.withConfiguration( // new OreFeatureConfig( // new TagMatchRuleTest(ModdedTags.AMETHYST_ORE_SPAWNABLE), // EvileDeferredRegistry.AMETHYST_ORE_OVERWORLD.get().getDefaultState(), // 7)) // .withPlacement(Placement.DEPTH_AVERAGE.configure( // new DepthAverageConfig(32, 32))) // .range(16)); // applyToLists(); } private static void applyToLists() { OVERWORLD_ORES = new ConfiguredFeature<?, ?>[] {AMETHYST_ORE_OVERWORLD, LEAD_ORE_OVERWORLD}; NETHER_ORES = new ConfiguredFeature<?, ?>[] {AMETHYST_ORE_NETHER, LEAD_ORE_NETHER}; END_ORES = new ConfiguredFeature<?, ?>[] {AMETHYST_ORE_END, LEAD_ORE_END}; } OreFeatureAdditionManager.java /** * Apply {@value #overworldOres()}, {@value #netherOres} and {@value #endOres} to {@link Biome}s * of their various {@link Biome.Category}. * * @param event */ @SubscribeEvent(priority = EventPriority.HIGH) //Subbed to FORGE public static void registerOres(final BiomeLoadingEvent event) { MagiksMostEvile.LOGGER.debug("Adding MME ores to biome: " + event.getName()); BiomeGenerationSettingsBuilder generation = event.getGeneration(); switch (event.getCategory()) { case NETHER: for (ConfiguredFeature<?, ?> simpleConfiguredOreFeature : OreFeatures.NETHER_ORES) { registerTo(generation, simpleConfiguredOreFeature); } break; case THEEND: for (ConfiguredFeature<?, ?> simpleConfiguredOreFeature : OreFeatures.END_ORES) { registerTo(generation, simpleConfiguredOreFeature); } break; default: for (ConfiguredFeature<?, ?> simpleConfiguredOreFeature : OreFeatures.OVERWORLD_ORES) { registerTo(generation, simpleConfiguredOreFeature); } break; } } /** * Convenience method to tidy up {@link #registerOres(BiomeLoadingEvent)} by abstracting away * {@link BiomeGenerationSettingsBuilder} calls. * * @param builder * @param feature */ private static void registerTo(BiomeGenerationSettingsBuilder builder, ConfiguredFeature<?, ?> feature) { builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, feature); } How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
December 27, 20204 yr 15 hours ago, GenElectrovise said: I've resolved the error: It was resulting from a NullPointerException while I was adding my features to biomes, which was concealed behind a resulting exception which was traced back to the mouseClickEventHandler which was triggered when I loaded the world. I was adding my features to a static ConfiguredFeature<?,?> [ ], before they were actually loaded, with the expectation that the array references would be updated as well, but I guess concurrency decided that wouldn't happen. Now the final call of my event handler populates the arrays and everything works fine. My new code is: OreFeaures.java public static ConfiguredFeature<?, ?>[] OVERWORLD_ORES; public static ConfiguredFeature<?, ?>[] NETHER_ORES; public static ConfiguredFeature<?, ?>[] END_ORES; @SubscribeEvent //Subbed to MOD public static void createConfiguredOreFeatures(FMLCommonSetupEvent event) { MagiksMostEvile.LOGGER.debug("Creating MME configured ore features"); // Amethyst Ore Overworld AMETHYST_ORE_OVERWORLD = Registry.register( // WorldGenRegistries.CONFIGURED_FEATURE, // "amethyst_ore_overworld_generation", // Feature.ORE.withConfiguration( // new OreFeatureConfig( // new TagMatchRuleTest(ModdedTags.AMETHYST_ORE_SPAWNABLE), // EvileDeferredRegistry.AMETHYST_ORE_OVERWORLD.get().getDefaultState(), // 7)) // .withPlacement(Placement.DEPTH_AVERAGE.configure( // new DepthAverageConfig(32, 32))) // .range(16)); // applyToLists(); } private static void applyToLists() { OVERWORLD_ORES = new ConfiguredFeature<?, ?>[] {AMETHYST_ORE_OVERWORLD, LEAD_ORE_OVERWORLD}; NETHER_ORES = new ConfiguredFeature<?, ?>[] {AMETHYST_ORE_NETHER, LEAD_ORE_NETHER}; END_ORES = new ConfiguredFeature<?, ?>[] {AMETHYST_ORE_END, LEAD_ORE_END}; } OreFeatureAdditionManager.java /** * Apply {@value #overworldOres()}, {@value #netherOres} and {@value #endOres} to {@link Biome}s * of their various {@link Biome.Category}. * * @param event */ @SubscribeEvent(priority = EventPriority.HIGH) //Subbed to FORGE public static void registerOres(final BiomeLoadingEvent event) { MagiksMostEvile.LOGGER.debug("Adding MME ores to biome: " + event.getName()); BiomeGenerationSettingsBuilder generation = event.getGeneration(); switch (event.getCategory()) { case NETHER: for (ConfiguredFeature<?, ?> simpleConfiguredOreFeature : OreFeatures.NETHER_ORES) { registerTo(generation, simpleConfiguredOreFeature); } break; case THEEND: for (ConfiguredFeature<?, ?> simpleConfiguredOreFeature : OreFeatures.END_ORES) { registerTo(generation, simpleConfiguredOreFeature); } break; default: for (ConfiguredFeature<?, ?> simpleConfiguredOreFeature : OreFeatures.OVERWORLD_ORES) { registerTo(generation, simpleConfiguredOreFeature); } break; } } /** * Convenience method to tidy up {@link #registerOres(BiomeLoadingEvent)} by abstracting away * {@link BiomeGenerationSettingsBuilder} calls. * * @param builder * @param feature */ private static void registerTo(BiomeGenerationSettingsBuilder builder, ConfiguredFeature<?, ?> feature) { builder.withFeature(GenerationStage.Decoration.UNDERGROUND_ORES, feature); } BiomeGenerationSettingsBuilder#withFeature() returns a new Builder with the passed in feature, it doesn't add the feature to the biomes generation. what you want to call is BiomeGenerationSettingsBuilder#getFeatures().add() you'll pass the generation stage you want your features to be generated in (Decoration.UNDERGROUND_ORES), and you pass a supplier of your feature to the add() method
December 28, 20204 yr Author On 12/27/2020 at 3:08 AM, kiou.23 said: BiomeGenerationSettingsBuilder#withFeature() returns a new Builder with the passed in feature, it doesn't add the feature to the biomes generation. what you want to call is BiomeGenerationSettingsBuilder#getFeatures().add() you'll pass the generation stage you want your features to be generated in (Decoration.UNDERGROUND_ORES), and you pass a supplier of your feature to the add() method Hmmm... strange. It seems to be working for me right now? By my researching withFeature(feature) both returns the builder, and adds the feature. I'll try changing that and see how that works. How to ask a good coding question: https://stackoverflow.com/help/how-to-ask Give logs, code, desired effects, and actual effects. Be thorough or we can't help you. Don't post code without putting it in a code block (the <> button on the post - select "C-type Language"): syntax highlighting makes everything easier, and it keeps the post tidy. My own mod, Magiks Most Evile: GitHub (https://github.com/GenElectrovise/MagiksMostEvile) Wiki (https://magiksmostevile.fandom.com/wiki/Magiks_Most_Evile_Wiki) Edit your own signature at https://www.minecraftforge.net/forum/settings/signature/
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.