Jump to content

Recommended Posts

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();
    }
}

 

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

Posted
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?

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

  • Like 1

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.