Hello
I would like to add a custom ore to the generation of the overworld. I followed some tutorials, but nothing works.
Here are my classe:
Main class:
@Mod(MyMod.MODID)
public class MyMod {
public static final String MODID = "mymod";
public static final Logger LOGGER = (Logger) LogManager.getLogger(MODID);
public MyMod() {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverSetup);
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
ModItems.ITEMS.register(bus);
ModBlocks.BLOCKS.register(bus);
}
private void setup(FMLCommonSetupEvent e) {
ModFeatures features = new ModFeatures();
features.init();
MinecraftForge.EVENT_BUS.register(features);
}
private void clientSetup(FMLClientSetupEvent e) {
MinecraftForge.EVENT_BUS.register(this);
}
private void serverSetup(FMLDedicatedServerSetupEvent e) {
}
}
ModFeatures class:
public class ModFeatures {
public ConfiguredFeature<?, ?> ORE_CUSTOM;
public void init() {
ORE_CUSTOM = register("custom_ore", Feature.ORE.configured(
new OreFeatureConfig(OreFeatureConfig.FillerBlockType.NATURAL_STONE,
ModBlocks.ORE_CUSTOM.get().defaultBlockState(),
2))
.range(20).squared()
.count(20));
}
public <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String name, ConfiguredFeature<FC, ?> feature) {
return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, name, feature);
}
@SubscribeEvent
public void biomeLoading(BiomeLoadingEvent e) {
BiomeGenerationSettingsBuilder generation = e.getGeneration();
if (e.getCategory() != Biome.Category.NETHER && e.getCategory() != Biome.Category.THEEND) {
generation.addFeature(GenerationStage.Decoration.UNDERGROUND_ORES, ORE_CUSTOM);
}
}
}
I get no error, but I can't find any custom ore. I don't know if it is because my values are too low (because I do not really understand how does work range() and count(): where are the min and the max Y level for generation?) or if I forgot something...
Thanks for your help.