Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

KakUserTask

Members
  • Joined

  • Last visited

  1. It helped, thank you! Here is the new code: package my.first.mod.myfirstmod; ... import static my.first.mod.myfirstmod.RegistryHandler.COPPER_ORE; @Mod("myfirstmod") public class MyFirstMod { private static final Logger LOGGER = LogManager.getLogger(); public static final String MODID = "myfirstmod"; public MyFirstMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); MinecraftForge.EVENT_BUS.register(this); RegistryHandler.init(); } private void setup(final FMLCommonSetupEvent event) { LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void doClientStuff(final FMLClientSetupEvent event) { LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings); } private void enqueueIMC(final InterModEnqueueEvent event) { InterModComms.sendTo("my-first-mod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world"; }); } private void processIMC(final InterModProcessEvent event) { LOGGER.info("Got IMC {}", event.getIMCStream(). map(m -> m.getMessageSupplier().get()). collect(Collectors.toList())); } @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { LOGGER.info("HELLO from server starting"); } @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents2 { public static ConfiguredFeature<?, ?> ORE_COPPER_CONFIG; public static int veinSize = 50; public static int veinCount = 50; public static int maxHeight = 120; @SubscribeEvent() public static void setup(FMLCommonSetupEvent event) { ORE_COPPER_CONFIG = Registry.register( WorldGenRegistries.CONFIGURED_FEATURE, "copper_ore", Feature.ORE.withConfiguration( new OreFeatureConfig( OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, COPPER_ORE.get().getDefaultState(), veinSize ) ).range(maxHeight).square().count(veinCount) ); LOGGER.info("'setup' function called"); } @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { LOGGER.info("HELLO from Register Block"); } } @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) public static class RegistryEvents { @SubscribeEvent(priority = EventPriority.HIGH) public static void onBiomeLoading(final BiomeLoadingEvent biome) { if(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND) return; biome.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES) .add(() -> RegistryEvents2.ORE_COPPER_CONFIG); LOGGER.info("'OnBiomeLoading' function called"); } } }
  2. package my.first.mod.myfirstmod; ... import static my.first.mod.myfirstmod.RegistryHandler.COPPER_ORE; @Mod("myfirstmod") public class MyFirstMod { private static final Logger LOGGER = LogManager.getLogger(); public static final String MODID = "myfirstmod"; public MyFirstMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); MinecraftForge.EVENT_BUS.register(this); RegistryHandler.init(); } private void setup(final FMLCommonSetupEvent event) { LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void doClientStuff(final FMLClientSetupEvent event) { LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings); } private void enqueueIMC(final InterModEnqueueEvent event) { InterModComms.sendTo("my-first-mod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world"; }); } private void processIMC(final InterModProcessEvent event) { LOGGER.info("Got IMC {}", event.getIMCStream(). map(m -> m.getMessageSupplier().get()). collect(Collectors.toList())); } @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { LOGGER.info("HELLO from server starting"); } @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE) public static class RegistryEvents { public static ConfiguredFeature<?, ?> ORE_COPPER_CONFIG; public static int veinSize = 50; public static int veinCount = 50; public static int maxHeight = 120; @SubscribeEvent public static void setup(FMLCommonSetupEvent event) { ORE_COPPER_CONFIG = Registry.register( WorldGenRegistries.CONFIGURED_FEATURE, "copper_ore", Feature.ORE.withConfiguration( new OreFeatureConfig( OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, COPPER_ORE.get().getDefaultState(), veinSize ) ).range(maxHeight).square().count(veinCount) ); LOGGER.info("'setup' function called"); } @SubscribeEvent(priority = EventPriority.HIGH) public void onBiomeLoading(final BiomeLoadingEvent biome) { if(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND) return; biome.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES) .add(() -> ORE_COPPER_CONFIG); LOGGER.info("'OnBiomeLoading' function called"); } @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { LOGGER.info("HELLO from Register Block"); } } } This is the updated code (as I understood it needed to be changed).
  3. Is this how it should be? But the method is still not called @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
  4. This is the main mod file. I assumed that onBiomeLoading is not being called. But I still did not understand why it was not called. Tried making the method static, but then an exception is thrown (java.lang.IllegalArgumentException: Method public static void 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). Tell me what I'm doing wrong. Thanks! import static my.first.mod.myfirstmod.RegistryHandler.COPPER_ORE; @Mod("myfirstmod") public class MyFirstMod { private static final Logger LOGGER = LogManager.getLogger(); public static final String MODID = "myfirstmod"; public MyFirstMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); MinecraftForge.EVENT_BUS.register(this); RegistryHandler.init(); } private void setup(final FMLCommonSetupEvent event) { LOGGER.info("HELLO FROM PREINIT"); LOGGER.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName()); } private void doClientStuff(final FMLClientSetupEvent event) { LOGGER.info("Got game settings {}", event.getMinecraftSupplier().get().gameSettings); } private void enqueueIMC(final InterModEnqueueEvent event) { InterModComms.sendTo("my-first-mod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world"; }); } private void processIMC(final InterModProcessEvent event) { LOGGER.info("Got IMC {}", event.getIMCStream(). map(m -> m.getMessageSupplier().get()). collect(Collectors.toList())); } @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { LOGGER.info("HELLO from server starting"); } @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { public static ConfiguredFeature<?, ?> ORE_COPPER_CONFIG; public static int veinSize = 12; public static int veinCount = 5; public static int maxHeight = 120; @SubscribeEvent public static void setup(FMLCommonSetupEvent event) { ORE_COPPER_CONFIG = Registry.register( WorldGenRegistries.CONFIGURED_FEATURE, "copper_ore", Feature.ORE.withConfiguration( new OreFeatureConfig( OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, COPPER_ORE.get().getDefaultState(), veinSize ) ).range(maxHeight).square().count(veinCount) ); LOGGER.info("'setup' function called"); } @SubscribeEvent(priority = EventPriority.HIGH) public void onBiomeLoading(final BiomeLoadingEvent biome) { if(biome.getCategory() == Biome.Category.NETHER || biome.getCategory() == Biome.Category.THEEND) return; biome.getGeneration().getFeatures(GenerationStage.Decoration.UNDERGROUND_ORES) .add(() -> ORE_COPPER_CONFIG); LOGGER.info("'OnBiomeLoading' function called"); } @SubscribeEvent public static void onBlocksRegistry(final RegistryEvent.Register<Block> blockRegistryEvent) { LOGGER.info("HELLO from Register Block"); } } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.