Posted May 17, 20205 yr I've looked at the DefaultBiomeFeatures class of the vanilla code and created this class in the mod folder in the world.gen packages: package com.SkySibe.testmod.world.gen; import com.SkySibe.testmod.init.BlockInit; import net.minecraft.block.BlockState; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.biome.DefaultBiomeFeatures; import net.minecraft.world.gen.GenerationStage; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.OreFeatureConfig; import net.minecraft.world.gen.placement.CountRangeConfig; import net.minecraft.world.gen.placement.Placement; import net.minecraftforge.registries.ForgeRegistries; public class genOre extends DefaultBiomeFeatures{ private static final BlockState RUBY_ORE = BlockInit.ruby_ore.getDefaultState(); public static void addRubyOre() { for (Biome biomeIn : ForgeRegistries.BIOMES) { if (biomeIn == Biomes.DARK_FOREST || biomeIn == Biomes.DARK_FOREST_HILLS) { biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, RUBY_ORE, 12)).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(0, 3, 9, 40)))); } else { biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, RUBY_ORE, 9)).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(0, 1, 6, 40)))); } } } } In the mod folder in the main mod class I've created the function 'loadCompleteEvent': package com.SkySibe.testmod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.SkySibe.testmod.world.gen.genOre; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; // The value here should match an entry in the META-INF/mods.toml file @Mod("testmod") public class TestMod { // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "testmod"; public static TestMod instance; public TestMod() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); instance = this; // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void doClientStuff(final FMLClientSetupEvent event) { } @SubscribeEvent public static void loadCompleteEvent() { genOre.addRubyOre(); } } I would like some help I'm pretty new to this although I've some experience with Java. btw I need help with adding xp to the ore mining, if you can tell me where do I find the vanilla class that doing it and how to modify it, it will help a lot. Thank.
May 17, 20205 yr You are overthinking it. You don't need to extend DefaultBiomeFeatures, just find one of the method calls in there that is adding ores, such as this from the addOres method: biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, IRON_ORE, 9)).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(20, 0, 0, 64)))); And then use a similar call to the Biome#addFeature method from your FMLCommonSetupEvent, using DeferredWorkQueue using your custom ore. *edit: also, that event you have setup will never fire, there's no method signature to indicate what event it is subscribed to Edited May 17, 20205 yr by Ugdhar
May 17, 20205 yr Just now, diesieben07 said: You need to also use DeferredWorkQueue, because addFeature is not threadsafe. Haha oops, I meant that instead of DeferredRegister, thanks, fixing it!
May 17, 20205 yr Author What should I need to do? I didn't understand... do I need to delete this function?: @SubscribeEvent public static void loadCompleteEvent() { genOre.addRubyOre(); } and insteand in this what should I call and how? private void setup(final FMLCommonSetupEvent event) { } and what should I change here except unusing extents? and how do I use DeferredWorkQueue insteand of addFeature?? public class genOre{ private static final BlockState RUBY_ORE = BlockInit.ruby_ore.getDefaultState(); public static void addRubyOre() { for (Biome biomeIn : ForgeRegistries.BIOMES) { if (biomeIn == Biomes.DARK_FOREST || biomeIn == Biomes.DARK_FOREST_HILLS) { biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, RUBY_ORE, 12)).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(0, 3, 9, 40)))); } else { biomeIn.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE, RUBY_ORE, 9)).withPlacement(Placement.COUNT_RANGE.configure(new CountRangeConfig(0, 1, 6, 40)))); } } } } Edited May 17, 20205 yr by SkySibe
May 17, 20205 yr Author 3 hours ago, diesieben07 said: You need to also use DeferredWorkQueue, because addFeature is not threadsafe. 3 hours ago, Ugdhar said: Haha oops, I meant that instead of DeferredRegister, thanks, fixing it! How do I do those?
May 17, 20205 yr Search these forums with the search bar at the top for DeferredWorkQueue and you will find an example in one of the results I am sure. I haven't looked, but there might also be documentation in the source for it as well.
May 17, 20205 yr Author 3 hours ago, Ugdhar said: Search these forums with the search bar at the top for DeferredWorkQueue and you will find an example in one of the results I am sure. I haven't looked, but there might also be documentation in the source for it as well. I didn't find any and didn't manage it to work, I'll appreciate your help thanks by far. Edited May 17, 20205 yr by SkySibe
May 17, 20205 yr Use DeferredWorkQueue.runLater(Runnable), DeferredWorkQueue is in the net.minecraftforge.fml package and is documented. There was an example of someone using it within the first page of search results. If something doesn't work, you need to post updated code (preferably just have a github repo for the project) and updated logs, and be more descriptive than "it didn't work". When all the details are present, a solution usually presents itself
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.