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