Posted July 4, 20196 yr My .toml for client and server configuration are generated but nothing is being printed into them to read and change. Any ideas? Plez don't judge me, the code is simple and i have alot of reminders as im new to forge. and yes its called custommod. im not planning on sharing it im kinda just messing around to play with learning forge. and not planning on mixing it with other mods so the modid custommod should be fine. Heres the Config.java Spoiler package com.kronches.custommod.config; import java.io.File; import com.electronwill.nightconfig.core.file.CommentedFileConfig; import com.electronwill.nightconfig.core.io.WritingMode; import com.kronches.custommod.Main; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber public class Config { private static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder(); public static final ForgeConfigSpec SERVER_CONFIG; private static final ForgeConfigSpec.Builder CLIENT_BUILDER = new ForgeConfigSpec.Builder(); public static final ForgeConfigSpec CLIENT_CONFIG; static { OreConfig.init(SERVER_BUILDER, CLIENT_BUILDER); SERVER_CONFIG = SERVER_BUILDER.build(); CLIENT_CONFIG = CLIENT_BUILDER.build(); } public static void loadConfig(ForgeConfigSpec config, String path) { Main.LOGGER.info("Loading Config :" + path); final CommentedFileConfig file = CommentedFileConfig.builder(new File(path)).sync().autosave().writingMode(WritingMode.REPLACE).build(); Main.LOGGER.info("Config Built: " + path); file.load(); Main.LOGGER.info("Loaded config:" + path); config.setConfig(file); } } My ore generation config Spoiler package com.kronches.custommod.config; import net.minecraftforge.common.ForgeConfigSpec; public class OreConfig { public static ForgeConfigSpec.IntValue copper_ore_chance; public static ForgeConfigSpec.IntValue sulfur_ore_chance; public static ForgeConfigSpec.IntValue titanium_ore_chance; public static ForgeConfigSpec.BooleanValue generate_overworld; public static ForgeConfigSpec.BooleanValue generate_nether; public static ForgeConfigSpec.BooleanValue generate_end; public static void init(ForgeConfigSpec.Builder server, ForgeConfigSpec.Builder client) { server.comment("OreGeneration Config for CustomMod"); copper_ore_chance = server .comment("Max copper spawning in one chunk.") .defineInRange("oregen.copper_ore_chance", 1000, 1, 100000); sulfur_ore_chance = server .comment("Max sulfur ore spawning in one chunk.") .defineInRange("oregen.sulfur_ore_chance", 1000, 1, 100000); titanium_ore_chance = server .comment("Max Titanium ore spawning in one chunk") .defineInRange("oregen.titanium_ore_chance", 1000, 1, 100000); server.comment("# end ore generation"); server.comment("-----------------------------------------------------------"); server.comment("WORLD CONFIGS DO NOT TOUCH IF YOU DONT KNOW WHAT YOUR DOING"); server.comment("-----------------------------------------------------------"); generate_overworld = server .comment("Can Custom Mod ores spawn in the overworld? default= true") .define("oregen.generate_overworld", true); generate_nether = server .comment("Can Custom Mod Generate our Nether ores? DEFAULT=true") .define("oregen.generate_nether", true); generate_end = server .comment("Can CustomMod generate our ore in the END? DEFAULT = true") .define("oregen.generate_end", true); } } My main class Spoiler package com.kronches.custommod; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import com.kronches.custommod.config.*; import com.kronches.custommod.items.ItemCustomAxe; import com.kronches.custommod.items.ItemCustomPickaxe; import com.kronches.custommod.lists.CustommodArmorMaterials; import com.kronches.custommod.lists.BlockList; import com.kronches.custommod.lists.ItemList; import com.kronches.custommod.lists.ToolMaterialList; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ArmorItem; import net.minecraft.item.BlockItem; import net.minecraft.item.HoeItem; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.item.ShovelItem; import net.minecraft.item.SwordItem; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLPaths; @Mod("custommod") public class Main { public static Main instance; public static final String MODID = "custommod"; public static final Logger LOGGER = LogManager.getLogger(MODID); public static final ItemGroup CUSTOMMOD = new CustomModItemGroup(); public Main() { instance = this; //CONFIGS AND LOADING ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, Config.SERVER_CONFIG); ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_CONFIG); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries); Config.loadConfig(Config.SERVER_CONFIG, FMLPaths.CONFIGDIR.get().resolve("custommod-client.toml").toString()); Config.loadConfig(Config.CLIENT_CONFIG, FMLPaths.CONFIGDIR.get().resolve("custommod-server.toml").toString()); //CONFIG LOAD DONE MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { LOGGER.info("Setup Method Registered"); } private void clientRegistries(final FMLClientSetupEvent event) { LOGGER.info("clientRegistries Method Registered"); } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { //Item List// //BRONZE event.getRegistry().registerAll ( //Materials ItemList.bronze = new Item(new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("bronze")), ItemList.steel = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("steel")), ItemList.sulfur = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("sulfur")), ItemList.carbon = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("carbon")), ItemList.tungsten_carbide = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("tungsten_carbide")), ItemList.tungsten = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("tungsten")), ItemList.titanium = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("titanium")), ItemList.copper = new Item (new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(location("copper")), //Tools // dmg to sword, AttackSpeed ItemList.steel_axe = new ItemCustomAxe(ToolMaterialList.steel, -3.0f, 6.0f, new Item.Properties().group(ItemGroup.TOOLS).group(CUSTOMMOD)).setRegistryName(location("steel_axe")), // AttackSpeed ItemList.steel_hoe = new HoeItem(ToolMaterialList.steel, 6.0f, new Item.Properties().group(ItemGroup.TOOLS).group(CUSTOMMOD)).setRegistryName(location("steel_hoe")), //same as axe dmg scailing ItemList.steel_pickaxe = new ItemCustomPickaxe(ToolMaterialList.steel, -5, 6.0f, new Item.Properties().group(ItemGroup.TOOLS).group(CUSTOMMOD)).setRegistryName(location("steel_pickaxe")), ItemList.steel_sword = new SwordItem(ToolMaterialList.steel, 0, 6.0f, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName(location("steel_sword")), ItemList.steel_shovel = new ShovelItem(ToolMaterialList.steel, -5, 6.0f, new Item.Properties().group(ItemGroup.TOOLS).group(CUSTOMMOD)).setRegistryName(location("steel_shovel")), //bronze ItemList.bronze_axe = new ItemCustomAxe(ToolMaterialList.bronze, -3.0f, 6.0f, new Item.Properties().group(ItemGroup.TOOLS).group(CUSTOMMOD)).setRegistryName(location("bronze_axe")), //Armour List ItemList.steel_helmet = new ArmorItem(CustommodArmorMaterials.steel, EquipmentSlotType.HEAD, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("steel_helmet"), ItemList.steel_chestplate = new ArmorItem(CustommodArmorMaterials.steel, EquipmentSlotType.CHEST, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("steel_chestplate"), ItemList.steel_chestplate = new ArmorItem(CustommodArmorMaterials.steel, EquipmentSlotType.LEGS, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("steel_leggings"), ItemList.steel_boots = new ArmorItem(CustommodArmorMaterials.steel, EquipmentSlotType.FEET, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("steel_boots"), ItemList.bronze_helmet = new ArmorItem(CustommodArmorMaterials.bronze, EquipmentSlotType.HEAD, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("bronze_helmet"), ItemList.bronze_chestplate = new ArmorItem(CustommodArmorMaterials.bronze, EquipmentSlotType.CHEST, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("bronze_chestplate"), ItemList.bronze_leggings = new ArmorItem(CustommodArmorMaterials.bronze, EquipmentSlotType.LEGS, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("bronze_leggings"), ItemList.bronze_boots = new ArmorItem(CustommodArmorMaterials.bronze, EquipmentSlotType.FEET, new Item.Properties().group(ItemGroup.COMBAT).group(CUSTOMMOD)).setRegistryName("bronze_boots"), //Blocks ItemList.steelblock = new BlockItem (BlockList.steelblock, new Item.Properties().group(ItemGroup.BUILDING_BLOCKS).group(CUSTOMMOD)).setRegistryName(BlockList.steelblock.getRegistryName()), ItemList.copper_ore = new BlockItem (BlockList.copper_ore, new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(BlockList.copper_ore.getRegistryName()), ItemList.sulfur_ore = new BlockItem (BlockList.sulfur_ore, new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(BlockList.sulfur_ore.getRegistryName()), ItemList.titanium_ore = new BlockItem (BlockList.titanium_ore, new Item.Properties().group(ItemGroup.MATERIALS).group(CUSTOMMOD)).setRegistryName(BlockList.titanium_ore.getRegistryName())) ; LOGGER.info("Items Registered"); } @SubscribeEvent public static void registerBlocks(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll ( BlockList.steelblock = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.METAL)).setRegistryName(location("steelblock")), BlockList.copper_ore = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.METAL)).setRegistryName(location("copper_ore")), BlockList.sulfur_ore = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.METAL)).setRegistryName(location("sulfur_ore")), BlockList.titanium_ore = new Block(Block.Properties.create(Material.IRON).hardnessAndResistance(2.0f, 3.0f).lightValue(0).sound(SoundType.METAL)).setRegistryName(location("titanium_ore")) ); LOGGER.info("Blocks Registered"); } } private static ResourceLocation location(String name) { return new ResourceLocation(MODID, name); } }
July 6, 20196 yr On 7/5/2019 at 4:36 AM, Kronches said: final CommentedFileConfig file = CommentedFileConfig.builder(new File(path)).sync().autosave().writingMode(WritingMode.REPLACE).build(); Main.LOGGER.info("Config Built: " + path); file.load(); Don’t do this. Register the configs to your ModLoadingContext and subscribe to the config change event. About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
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.