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.

Featured Replies

  • Author
2 minutes ago, diesieben07 said:

If you do not register your configured features you will break any other mods with world generation. 
Register your configured features in FMLCommonSetupEvent#enqueueWork.

Yes I did it.

  • Author

So, going back to what I was saying, this was my solution after so much talk:

 

The Main:

@Mod(ExampleMod.modid)
public class ExampleMod {
    public static final String modid = "examplemod";
    private static final Logger LOGGER = LogManager.getLogger("examplemod");
    public static final CreativeModeTab examplemod = new ExampleTab();

    public ExampleMod() {
        IEventBus modEventbus = FMLJavaModLoadingContext.get().getModEventBus();

        ExampleBlocks.BLOCKS.register(modEventbus);
        ExampleItems.ITEMS.register(modEventbus);

        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);

        ModLoadingContext.get().registerConfig(Type.COMMON, GWorldConfig.SPEC, "example-common.toml");

        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event) {
        event.enqueueWork(() -> {
            OreGeneration.registerConfiguredFeatures();
        });
        LOGGER.info("Hello from preinit");
        LOGGER.info("Dirt block >> {}", Blocks.DIRT.getRegistryName());
    }

    @OnlyIn(Dist.CLIENT)
    public void clientSetup(FMLClientSetupEvent event) {
        LOGGER.info("Hello from client setup");
    }

    @SubscribeEvent
    public void serverStarting(FMLServerStartingEvent event) {
        LOGGER.info("Hello from server starting");
    }

    @EventBusSubscriber(bus = Bus.MOD)
    public static class RegistryEvents {
        public RegistryEvents() {
        }

        @SubscribeEvent
        public static void registerBlocks(final RegistryEvent.Register<Block> event) {
            LOGGER.info("Hello from Register Block");
        }
    }
}

 

 

The Config: 

public class ExampleConfig {
    public static final Builder BUILDER = new Builder();
    public static final ForgeConfigSpec SPEC;
    public static final ConfigValue<Boolean> EXAMPLE_ORE_GENERATION;
    public static final ConfigValue<Integer> EXAMPLE_ORE_SIZE;
    public static final ConfigValue<Integer> EXAMPLE_ORE_MIN_HEIGHT;
    public static final ConfigValue<Integer> EXAMPLE_ORE_MAX_HEIGHT;
    public static final ConfigValue<Integer> EXAMPLE_ORE_CHANCE;

    public ExampleConfig() {
    }

    static {
        BUILDER.push("Example ore generation");
        EXAMPLE_ORE_GENERATION = BUILDER.define("Generate kyptoite ore", true);
        EXAMPLE_ORE_SIZE = BUILDER.define("Example ore vein size", 4);
        EXAMPLE_ORE_MIN_HEIGHT = BUILDER.define("Minimum example ore generation height", 0);
        EXAMPLE_ORE_MAX_HEIGHT = BUILDER.define("Maximum example ore generation height", 16);
        EXAMPLE_ORE_CHANCE = BUILDER.define("Chance of generate example ore", 1);
        BUILDER.pop();
        SPEC = BUILDER.build();
    }
}

 

 

The OreGeneration: 

@EventBusSubscriber
public class OreGeneration {
    public static ImmutableList<TargetBlockState> EXAMPLE_ORE_TARGET_LIST;
    public static ConfiguredFeature<?, ?> EXAMPLE_ORE;

    public OreGeneration() {
    }

    public static void registerConfiguredFeatures() {
        EXAMPLE_ORE_TARGET_LIST = ImmutableList.of(OreConfiguration.target(Predicates.NATURAL_STONE, ((Block) ExampleBlocks.KYPTOITE_ORE.get()).defaultBlockState()), OreConfiguration.target(Predicates.STONE_ORE_REPLACEABLES, ((Block) ExampleBlocks.KYPTOITE_ORE.get()).defaultBlockState()));
        EXAMPLE_ORE = (ConfiguredFeature)((ConfiguredFeature)((ConfiguredFeature) Feature.ORE.configured(new OreConfiguration(EXAMPLE_ORE_TARGET_LIST, (Integer) ExampleConfig.EXAMPLE_ORE_SIZE.get())).rangeUniform(VerticalAnchor.absolute((Integer) ExampleConfig.EXAMPLE_ORE_MIN_HEIGHT.get()), VerticalAnchor.absolute((Integer) ExampleConfig.EXAMPLE_ORE_MAX_HEIGHT.get()))).squared()).count((Integer) ExampleConfig.EXAMPLE_ORE_CHANCE.get());
        Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new ResourceLocation("examplemod", "example_ore"), EXAMPLE_ORE);
    }

    @SubscribeEvent(priority = EventPriority.HIGH)
    public static void registerBiomeModification(BiomeLoadingEvent event) {
        event.getGeneration().getFeatures(Decoration.UNDERGROUND_ORES).add(() -> {
            return EXAMPLE_ORE;
        });
    }
}

 

 

And this was the solution that I found with the help of Grookey, Luis_ST and diesieben07

Edited by Gianka1485

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...

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.