Jump to content

Recommended Posts

Posted (edited)

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.

Edited by GoldFrite

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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