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

Posted

Hi, I've created a couple items, recipes, and blocks that I would like to be able to enable and disable with my mod config.

How do I disable these in a clean way? I'm unsure what the best practice here would be, and particularly lost on how to disable recipes. Would love a point in the right direction


Simplified versions of my implementation of config/registers are below if useful
ModBlocks.Java

public static final RegistryObject<Block> TIN_ORE_DEEPSLATE = registerBlock("tin_ore_deepslate",
            () -> new DropExperienceBlock(BlockBehaviour
                    .Properties.of(Material.STONE)
                    .strength(3f)
                    .requiresCorrectToolForDrops(), UniformInt.of(3,7)));
  
private static <T extends Block> RegistryObject<T> registerBlock(String name, Supplier<T> block) {
        RegistryObject<T> toReturn = BLOCKS.register(name, block);
        registerBlockItem(name, toReturn);
        return toReturn;
    }

    private static <T extends Block> RegistryObject<Item> registerBlockItem(String name, RegistryObject<T> block) {
        return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
    }


    public static void register(IEventBus eventBus) {
        BLOCKS.register(eventBus);
    }

ModItems.java
 

public static final RegistryObject<Item> TIN_RAW = ITEMS.register("tin_raw", () -> new Item(new Item.Properties()));

    public static void register(IEventBus eventBus) {
        ITEMS.register(eventBus);
    }

main

	IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, GrassblockEssentialsCommonConfig.SPEC, "mymod-common.toml");
        
        ModItems.register(modEventBus);
        ModBlocks.register(modEventBus);

        modEventBus.addListener(this::commonSetup);

        MinecraftForge.EVENT_BUS.register(this);

        modEventBus.addListener(this::addCreative);

commonconfig

public class CommonConfig {
    public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
    public static final ForgeConfigSpec SPEC;

    public static final ForgeConfigSpec.ConfigValue<Boolean> TIN_ENABLED;

    static{
        BUILDER.push("My Mod Config");

        TIN_ENABLED = BUILDER.comment("Enable Ore Types").define("Tin Enabled", true);

        BUILDER.pop();
        SPEC = BUILDER.build();
    }
}

 

4 hours ago, Lexjp said:

How do I disable these in a clean way? I'm unsure what the best practice here would be, and particularly lost on how to disable recipes. Would love a point in the right direction

Don't. There's a number of issues that can occur when attempting to disable a particular feature. You should either leave the configuration up to the user through the datapack to disable specific recipes or ore generation. Alternatively if this is really necessary, you could use the config with a conditional on the given feature placement and the recipe conditions.

  • Author
14 hours ago, ChampionAsh5357 said:

Don't. There's a number of issues that can occur when attempting to disable a particular feature. You should either leave the configuration up to the user through the datapack to disable specific recipes or ore generation. Alternatively if this is really necessary, you could use the config with a conditional on the given feature placement and the recipe conditions.

I'm a bit lost on how to use the datapack to disable ore gen / recipes. Any resources you could point me to?

9 hours ago, Lexjp said:

I'm a bit lost on how to use the datapack to disable ore gen / recipes. Any resources you could point me to?

I can point you to the Minecraft wiki as, like I said, a user playing your mod can simply disable the recipes and ore generation themselves through a datapack. If someone really wants to disable your stuff, there is already a way to do so without your intervention.

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.