Jump to content

[SOLVED] Config Problems


mardiff

Recommended Posts

As I have no experiences thus far with config files, I tried to make one, yet failed. Here is the complete set of code for the ConfigHandler:

package mardiff.quartz.lib;

import java.io.File;

import net.minecraftforge.common.Configuration;

public class ConfigHandler {
public static void init(File configFile) {
	Configuration config = new Configuration(configFile);

	config.load();

	//Blocks
	BlockIds.QUARTZ_CRYSTAL_BLOCK = config.getBlock("Quartz Crystal Block", BlockIds.QUARTZ_CRYSTAL_BLOCK_DEFAULT).getInt();
	//BlockIds.QUARTZ_ORE = config.getBlock(Quartz Block, BlockIds.QUARTZ_ORE_DEFAULT).getInt();

	//Items
	ItemIds.QUARTZ_SWORD = config.getItem("Quartz Sword", ItemIds.QUARTZ_SWORD_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_SHOVEL = config.getItem("Quartz Shovel", ItemIds.QUARTZ_SHOVEL_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_PICK = config.getItem("Quartz Pickaxe", ItemIds.QUARTZ_PICK_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_AXE = config.getItem("Quartz Axe", ItemIds.QUARTZ_AXE_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_HOE = config.getItem("Quartz Hoe", ItemIds.QUARTZ_HOE_DEFAULT).getInt() - 256;

	ItemIds.QUARTZ_HELM = config.getItem("Quartz Helm", ItemIds.QUARTZ_HELM_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_CHEST = config.getItem("Quartz Chest", ItemIds.QUARTZ_CHEST_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_LEGS = config.getItem("Quartz Legs", ItemIds.QUARTZ_LEGS_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_BOOTS = config.getItem("Quartz Boots", ItemIds.QUARTZ_BOOTS_DEFAULT).getInt() - 256;

	ItemIds.QUARTZ_CHISEL = config.getItem("Diamond Chisel", ItemIds.QUARTZ_CHISEL_DEFAULT).getInt() - 256;
	ItemIds.QUARTZ_CARVED_QUARTZ = config.getItem("Quartz Crystal", ItemIds.QUARTZ_CARVED_QUARTZ_DEFAULT).getInt() - 256;

	config.save();
}
}

 

Addtionally, this line is in the PreInit of my main class:

ConfigHandler.init(event.getSuggestedConfigurationFile());

 

The problem is that when I try to open an existing world or make a new one, instead of giving me an error, the game simply kicks the game out to the title screen, and only then when you open the world again does it freeze the console. The console doesn't give any errors, so that doesn't help, and the config file itself looks just like it should. Any help would be appreciated.

Thanks,

Mardiff

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Link to comment
Share on other sites

Not sure if you set your config file up right, Here is the way I have mine set up

 

Main class

 

 

package kakarotvg.omega;

 

import kakarotvg.omega.generation.WorldGen;

import kakarotvg.omega.handlers.IDs.BlockIDs;

import kakarotvg.omega.handlers.IDs.ArmorIDs;

import kakarotvg.omega.handlers.IDs.ItemIDs;

import kakarotvg.omega.handlers.IDs.ToolIDs;

import kakarotvg.omega.handlers.armor.ArmorHandler;

import kakarotvg.omega.handlers.blocks.BlockHandler;

import kakarotvg.omega.handlers.crafting.CraftingHandler;

import kakarotvg.omega.handlers.creativetab.CreativetabHandler;

import kakarotvg.omega.handlers.crops.CropHandler;

import kakarotvg.omega.handlers.events.VgEventHandler;

import kakarotvg.omega.handlers.gui.GuiHandler;

import kakarotvg.omega.handlers.item.ItemHandler;

import kakarotvg.omega.handlers.liquids.LiquidHandler;

import kakarotvg.omega.handlers.tileentity.TileEntityHandler;

import kakarotvg.omega.handlers.tools.ToolHandler;

import kakarotvg.omega.proxys.CommonProxy;

import net.minecraftforge.common.Configuration;

import net.minecraftforge.common.MinecraftForge;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.event.FMLPostInitializationEvent;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.common.network.NetworkRegistry;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.common.registry.LanguageRegistry;

 

@Mod(modid = Reference.MOD_ID, name = Reference.MOD_N, version = Reference.MOD_V)

@NetworkMod(serverSideRequired = false, clientSideRequired = true, channels = Reference.channels, packetHandler = VgPacketHandler.class)

public class Omega {

 

    @Instance(Reference.MOD_ID)

    public static Omega instance;

    private GuiHandler guihandler = new GuiHandler();

 

    @SidedProxy(clientSide = "kakarotvg.omega.proxys.ClientProxy", serverSide = "kakarotvg.omega.proxys.CommonProxy")

    public static CommonProxy proxy;

 

    @EventHandler

    public void preInit(FMLPreInitializationEvent event) {

        Configuration config = new Configuration(event.getSuggestedConfigurationFile());

        config.load();

        BlockIDs.configureBlockIDs(config);

        ArmorIDs.configureArmorIDs(config);

        ToolIDs.ConfigureToolIDs(config);

        ItemIDs.ConfigureItemIDs(config);

        config.save();

 

        VgEventHandler.Events();

        VgEventHandler.registerSound();

 

        BlockHandler.configureBlocks(config);

        BlockHandler.registerBlocks(new GameRegistry());

        BlockHandler.setNames(new LanguageRegistry());

        BlockHandler.setHarvestlevel(new MinecraftForge());

 

        ItemHandler.configureItems(config);

        ItemHandler.registerItems(new GameRegistry());

        ItemHandler.setNames(new LanguageRegistry());

 

        ToolHandler.configureTools(config);

        ToolHandler.registerItem(new GameRegistry());

        ToolHandler.setNames(new LanguageRegistry());

        ToolHandler.setToolClass(new MinecraftForge());

 

        ArmorHandler.configreArmor(config);

        ArmorHandler.registerArmor(new GameRegistry());

        ArmorHandler.setNames(new LanguageRegistry());

 

        CropHandler.configurecrops(config);

        CropHandler.registercrops(new GameRegistry());

        CropHandler.addnames(new LanguageRegistry());

 

        CreativetabHandler.setNames(new LanguageRegistry());

 

        LiquidHandler.configurefluids(config);

        LiquidHandler.registerfluids(new GameRegistry());

        LiquidHandler.addNames(new LanguageRegistry());

        LiquidHandler.fluidContainerRegistry();

 

        TileEntityHandler.configureTileEntitys(config);

        TileEntityHandler.registerTileEntitys(new GameRegistry());

        TileEntityHandler.addNames(new LanguageRegistry());

        TileEntityHandler.tileentityRegistry(new GameRegistry());

 

        GameRegistry.registerWorldGenerator(new WorldGen());

        NetworkRegistry.instance().registerGuiHandler(this, guihandler);

 

        CraftingHandler.addCrafting(new GameRegistry());

        CraftingHandler.addSmelting(new GameRegistry());

 

        // loads the init method of Commonproxy

        proxy.init();

 

    }

 

    @EventHandler

    public void Init(FMLInitializationEvent event) {

 

    }

 

    @EventHandler

    public void postInit(FMLPostInitializationEvent event) {

 

    }

 

}

 

 

 

 

block Ids

 

 

package kakarotvg.omega.handlers.IDs;

 

import net.minecraftforge.common.Configuration;

 

public class BlockIDs {

 

    // config categories

    public static String urotarkids = "Urotark IDs";

    public static String muscoviteids = "Muscovite IDs";

    public static String gilderids = "Gilder IDs";

    public static String bariumids = "Barium IDs";

    public static String vanadiumids = "Vanadium IDs";

    public static String bismuthids = "Bismuth IDs";

    public static String platinumids = "Platinum IDs";

    public static String berionvarids = "Berionvar IDs";

    public static String firlvearids = "Firlvear IDs";

    public static String verilionids = "Verilion IDs";

    public static String bubbleids = "Bubble IDs";

    public static String darknessids = "Darkness IDs";

    public static String omegaids = "Omega IDs";

    public static String liquidids = "Liquid IDs";

    public static String cropids = "Crop IDs";

    public static String unknownids = "??? IDs";

    public static String tileentityids = "Tile Entity IDs";

 

    // BLOCK IDS

    // urotark ids

    public static int urotarkoreID;

    public static int urotarkblockID;

    // pearl IDs

    public static int pearloreID;

    public static int pearlblockID;

    // sapphire IDs

    public static int sapphireoreID;

    public static int sapphireblockID;

    // muscovite IDs

    public static int muscoviteoreID;

    public static int muscoviteblockID;

    // ruby IDs

    public static int rubyoreID;

    public static int rubyblockID;

    // uriotyke IDs

    public static int uriotykeoreID;

    public static int uriotykeblockID;

    // gilder IDs

    public static int gilderoreID;

    public static int gilderblockID;

    // selovar IDs

    public static int selovaroreID;

    public static int selovarblockID;

    // parfilian IDs

    public static int parfilianoreID;

    public static int parfilianblockID;

    // barium IDs

    public static int bariumoreID;

    public static int bariumblockID;

    // radium IDs

    public static int radiumoreID;

    public static int radiumblockID;

    // gallum IDs

    public static int gallumoreID;

    public static int gallumblockID;

    // vanadium IDs

    public static int vanadiumoreID;

    public static int vanadiumblockID;

    // scandium IDs

    public static int scandiumoreID;

    public static int scandiumblockID;

    // bismuth IDs

    public static int bismuthoreID;

    public static int bismuthblockID;

    // indium IDs

    public static int indiumoreID;

    public static int indiumblockID;

    // platinum IDs

    public static int platinumoreID;

    public static int platinumblockID;

    // berionvar IDs

    public static int berionvaroreID;

    public static int berionvarblockID;

    // charviole IDs

    public static int charvioleoreID;

    public static int charvioleblockID;

    // firlvear IDs

    public static int firlvearoreID;

    public static int firlvearblockID;

    // selmenrer IDs

    public static int selmenreroreID;

    public static int selmenrerblockID;

    // verilion IDs

    public static int verilionoreID;

    public static int verilionblockID;

    // vielvor IDs

    public static int vielvororeID;

    public static int vielvorblockID;

    // bubble IDs

    public static int bubbleblockID;

    // darkness IDs

    public static int darknessoreID;

    public static int darknessblockID;

    // light IDs

    public static int lightoreID;

    public static int lightblockID;

    // omega IDs

    public static int omegaoreID;

    public static int omegablockID;

    // unknown IDs

    public static int unknownID;

 

    // LIQUID IDS

    public static int darknessfluidID;

    public static int lightfluidID;

 

    // CROP IDS

    public static int darknesscropID;

    public static int lightcropID;

 

    // TILE ENTITY IDS

    public static int darknesssolidID;

    public static int computeridleID;

    public static int underworldchestID;

 

    public static void configureBlockIDs(Configuration config) {

        // BLOCK IDS   

        // urotark ids

        urotarkblockID = config.get(urotarkids, "Urotark Block", 2500).getInt();

        // muscovite ids

        muscoviteblockID = config.get(muscoviteids, "Muscovite Block", 2501).getInt();

        // gilder ids

        gilderblockID = config.get(gilderids, "Gilder Block", 2502).getInt();

        // barium ids

        bariumblockID = config.get(bariumids, "Barium Block", 2503).getInt();

        // vanadium ids

        vanadiumblockID = config.get(vanadiumids, "Vanadium Block", 2504).getInt();

        // bismuth ids

        bismuthblockID = config.get(bismuthids, "Bismuth Block", 2505).getInt();

        // platinum ids

        platinumblockID = config.get(platinumids, "Platinums Block", 2506).getInt();

        // berionvar ids

        berionvarblockID = config.get(berionvarids, "Berionvar Block", 2507).getInt();

        // firlvear ids

        firlvearblockID = config.get(firlvearids, "Firlvear Block", 2508).getInt();

        // verilion ids

        verilionblockID = config.get(verilionids, "Verilion Block", 2509).getInt();

        // bubble ids

        bubbleblockID = config.get(bubbleids, "Bubble Block", 2510).getInt();

        // darkness ids

        darknessblockID = config.get(darknessids, "Darkness Block", 2511).getInt();

        // omega ids

        omegablockID = config.get(omegaids, "Omega Block", 2512).getInt();

        // unknown ids

        unknownID = config.get(unknownids, "???", 2513).getInt();

        // ORE IDS

        // urotark

        urotarkoreID = config.get(urotarkids, "Urotark Ore", 2514).getInt();

        // muscovite

        muscoviteoreID = config.get(muscoviteids, "Muscovite Ore", 2515).getInt();

        // gilder

        gilderoreID = config.get(gilderids, "Gilder Ore", 2516).getInt();

        // barium

        bariumoreID = config.get(bariumids, "Barium Ore", 2517).getInt();

        // vanadium

        vanadiumoreID = config.get(vanadiumids, "Vanadium Ore", 2518).getInt();

        // bismuth

        bismuthoreID = config.get(bismuthids, "Bismuth Ore", 2519).getInt();

        // platinum

        platinumoreID = config.get(platinumids, "Platinums Ore", 2520).getInt();

        // berionvar

        berionvaroreID = config.get(berionvarids, "Berionvar Ore", 2521).getInt();

        // firlvear

        firlvearoreID = config.get(firlvearids, "Firlvear Ore", 2522).getInt();

        // verilion

        verilionoreID = config.get(verilionids, "Verilion Ore", 2523).getInt();

        // darkness

        darknessoreID = config.get(darknessids, "Darkness Ore", 2524).getInt();

        // omega

        omegaoreID = config.get(omegaids, "Omega Ore", 2525).getInt();

 

        //LIQUID IDS

        darknessfluidID = config.get(liquidids, "Darkness Fluid", 2526).getInt();

        lightfluidID = config.get(liquidids, "Light Fluid", 2527).getInt();

 

        // CROP IDS

        darknesscropID = config.get(cropids, "Darkness Crop", 2528).getInt();

        lightcropID = config.get(cropids, "Light Crop", 2529).getInt();

 

        // TILEENTITY IDS

        darknesssolidID = config.get(tileentityids, "Darkness Extrapalator", 2850).getInt();

        computeridleID = config.get(tileentityids, "Computer", 2851).getInt();

        underworldchestID = config.get(tileentityids, "Chest of the Underworld", 2853).getInt();

    }

 

}

 

 

 

if (You.likescoding == false){
      You.goaway;
}

Link to comment
Share on other sites

Try using config.get() instead of config.getBlock or config.getItem:

 

myBlockID = config.get(config.CATEGORY_BLOCK, "myBlockID", 1000).getInt();

 

The methods you're using are expecting a String comment parameter that you're not passing which might be problematic.

 

    public Property getItem(String category, String key, int defaultID, String comment)
    {
        Property prop = get(category, key, -1, comment);

Link to comment
Share on other sites

Try using config.get() instead of config.getBlock or config.getItem:

 

myBlockID = config.get(config.CATEGORY_BLOCK, "myBlockID", 1000).getInt();

 

The methods you're using are expecting a String comment parameter that you're not passing which might be problematic.

 

    public Property getItem(String category, String key, int defaultID, String comment)
    {
        Property prop = get(category, key, -1, comment);

 

It worked! Thanks!

If you really want help, give that modder a thank you.

 

Modders LOVE thank yous.

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.