
KakUserTask
Members-
Posts
4 -
Joined
-
Last visited
KakUserTask's Achievements

Tree Puncher (2/8)
0
Reputation
-
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"); } } }
-
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).
-
Is this how it should be? But the method is still not called @Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
-
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"); } } }