Jump to content

Problem with making a configuration file!


sartharis

Recommended Posts

So I made a config file using a few tutorials, but it doesn't seem to work. It appears and everything, but when I change the numbers, nothing changes.

 

Here are the two files:

 

mod_Goblins (Only the important part shown):

 

 static
   {
   GOBLINmodHelper.initProps();
}

  //Blocks---------------------------------------------------------------------------------------------------------------------------------
   //public static final Block fireplace = new GOBLINBlockFireplace(200, 0).setHardness(1F).setResistance(1F).setBlockName("fireplace");
   public static final Block MobGSpawner = new GOBLINBlockMobGSpawner(GOBLINmodHelper.MobGSpawnerBlockID, 0, GOBLINmodHelper.SpawnerRandSpawnrate1).setHardness(4F).setResistance(1F).setBlockName("BlockMobGSpawner");
   public static final Block MobGRSpawner = new GOBLINBlockMobGRSpawner(GOBLINmodHelper.MobGRSpawnerBlockID, 0,GOBLINmodHelper.SpawnerRandSpawnrate2).setHardness(4F).setResistance(1F).setBlockName("BlockMobGRSpawner");
   public static final Block MobGMSpawner = new GOBLINBlockMobGMSpawner(GOBLINmodHelper.MobGMSpawnerBlockID, 0, GOBLINmodHelper.SpawnerRandSpawnrate3).setHardness(4F).setResistance(1F).setBlockName("BlockMobGMSpawner");      
   public static final Block VillageSpawn = new GOBLINBlockVillageSpawn (GOBLINmodHelper.VillageSpawnBlockID,1).setHardness(0.1F).setResistance(1F).setBlockName("VillageSpawn").setLightValue(0.65F);
   public static final Block ETNT = new GOBLINBlockETNT (GOBLINmodHelper.ETNTBlockID,2).setHardness(0.0F).setBlockName("ETNT").setLightValue(0.65F);
   public static final Block MTNT = new GOBLINBlockMTNT (GOBLINmodHelper.MTNTBlockID,5).setHardness(0.0F).setBlockName("MTNT").setLightValue(0.8F);
   public static final Block totemR = new GOBLINBlockTotemR (GOBLINmodHelper.totemRBlockID,.setHardness(3.5F).setResistance(20F).setBlockName("totemR").setLightValue(0.65F);
   public static final Block totemB = new GOBLINBlockTotemB (GOBLINmodHelper.totemBBlockID,10).setHardness(3.5F).setResistance(20F).setBlockName("totemB").setLightValue(0.5F);
   public static final Block totemG = new GOBLINBlockTotemG (GOBLINmodHelper.totemGBlockID,12).setHardness(3.5F).setResistance(20F).setBlockName("totemG").setLightValue(0.5F);
   public static final Block totemY = new GOBLINBlockTotemY (GOBLINmodHelper.totemYBlockID,14).setHardness(3.5F).setResistance(20F).setBlockName("totemY").setLightValue(0.65F);
   public static final Block gobDrum = new GOBLINBlockGobDrum (GOBLINmodHelper.gobDrumBlockID).setHardness(0.8F).setBlockName("gobDrum").setRequiresSelfNotify();
   public static final Block gobStone = new GOBLINBlockGobStone(GOBLINmodHelper.gobStoneBlockID,16).setHardness(1.5F).setResistance(10F).setBlockName("gobStone");
   //public static final Block gobSlabStone = new BlockGobSlabStone(213, 0).setHardness(2.0F).setResistance(10F).setBlockName("gobSlabStone");
   public static final Block gobSlabWood = new GOBLINBlockGobSlabWood(GOBLINmodHelper.gobSlabWoodBlockID, 17).setHardness(2.0F).setResistance(10F).setBlockName("gobSlabWood");
    

 

And GOBLINmodHelper:

 

package net.minecraft.src;
import java.io.File;
import java.io.IOException;

import net.minecraft.client.Minecraft;
import net.minecraft.src.forge.Configuration;

public class GOBLINmodHelper {

    public static void initProps()
    {

        File file = new File(Minecraft.getMinecraftDir() + "/config/GoblinsConfig");
        file.mkdir();
        File newFile = new File(Minecraft.getMinecraftDir() + "/config/GoblinsConfig/GoblinsConfig.cfg");

        try
        {
            newFile.createNewFile();
            System.out.println("Successfully created/read Integer.parseInt(configuration file");
        }
        catch (IOException e)
        {
            System.out.println("Could not create Integer.parseInt(configuration file for mod_HelloWorld. Reason:");
            System.out.println(e);
        }

        Configuration configuration = new Configuration(newFile);

       configuration.load();
   
                MobGSpawnerBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner 1 ID ", Configuration.CATEGORY_BLOCK, 201).value );
			MobGRSpawnerBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner 2 ID ",Configuration.CATEGORY_BLOCK, 202).value );
			MobGMSpawnerBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner 3 ID ",Configuration.CATEGORY_BLOCK, 203).value );
			VillageSpawnBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Village Spawner ID ",Configuration.CATEGORY_BLOCK, 204).value );
			ETNTBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Enchanted TNT ID ",Configuration.CATEGORY_BLOCK, 205).value );
			MTNTBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Arcane TNT ID ",Configuration.CATEGORY_BLOCK, 206).value );
			totemRBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Red Totem ID ",Configuration.CATEGORY_BLOCK, 207).value );
			totemBBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Blue Totem ID ",Configuration.CATEGORY_BLOCK, 208).value );
			totemGBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Green Totem ID ",Configuration.CATEGORY_BLOCK, 209).value );
			totemYBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Yellow Totem ID ",Configuration.CATEGORY_BLOCK, 210).value );
			gobDrumBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Drum ID ",Configuration.CATEGORY_BLOCK, 211).value );
			gobStoneBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Stone ID ",Configuration.CATEGORY_BLOCK, 212).value );
			gobSlabWoodBlockID = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Wood Slab ID ",Configuration.CATEGORY_BLOCK, 213).value );

                swordFireShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Flame Blade ID ", Configuration.CATEGORY_ITEM, 348).value );
			GoblinFleshShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Flesh ID ", Configuration.CATEGORY_ITEM, 349).value );
			bombShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Bomb ID ", Configuration.CATEGORY_ITEM, 350).value );
			staffBlueShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Arcane Staff ID ", Configuration.CATEGORY_ITEM, 351).value );
			staffNatureShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Scepter of Life ID ", Configuration.CATEGORY_ITEM, 352).value );
			ShurikenShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Shuriken ID ", Configuration.CATEGORY_ITEM, 353).value );
			arrowGShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Nature Arrow ID ", Configuration.CATEGORY_ITEM, 354).value );
			arrowRShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Explosive Arrow ID ", Configuration.CATEGORY_ITEM, 355).value );
			arrowYShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Lighting Arrow ID ", Configuration.CATEGORY_ITEM, 356).value );
			crystalBShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Blue Crystal ID ", Configuration.CATEGORY_ITEM, 357).value );
			crystalRShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Red Crystal ID ", Configuration.CATEGORY_ITEM, 358).value );
			crystalGShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Green Crystal ID ", Configuration.CATEGORY_ITEM, 359).value );
			crystalYShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Yellow Crystal ID ", Configuration.CATEGORY_ITEM, 360).value );
			powderRShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Red Powder ID ", Configuration.CATEGORY_ITEM, 361).value );
			powderBShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Blue Powder ID ", Configuration.CATEGORY_ITEM, 362).value );
			powderYShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Yellow Powder ID ", Configuration.CATEGORY_ITEM, 363).value );
			powderGShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Green Powder ID ", Configuration.CATEGORY_ITEM, 364).value );
			katanaSwordShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Katana ID ", Configuration.CATEGORY_ITEM, 365).value );
			staffTeleportShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Teleportation Staff ID ", Configuration.CATEGORY_ITEM, 366).value );
			staffLightningShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Lightning Staff ID ", Configuration.CATEGORY_ITEM, 367).value );
			ectoplasmShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Ectoplasm ID ", Configuration.CATEGORY_ITEM, 368).value );
			GoblinBowShiftedIndex = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Bow ID ", Configuration.CATEGORY_ITEM, 369).value );

			GoblinRandSpawnrate1 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawnrate How often should goblins spawn in the wild ", Configuration.CATEGORY_GENERAL, 1).value );
			GoblinRandSpawnrate2 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawnrate min goblins in group but is often much less foor some reason ", Configuration.CATEGORY_GENERAL, 10).value );
			GoblinRandSpawnrate3 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawnrate max goblins in group but is often much less foor some reason ", Configuration.CATEGORY_GENERAL, 25).value );

			SpawnerRandSpawnrate1 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Spawner Delay ", Configuration.CATEGORY_GENERAL, 280).value );
			SpawnerRandSpawnrate2 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Rider and Direwolf Spawner Delay ", Configuration.CATEGORY_GENERAL, 230).value );
			SpawnerRandSpawnrate3 = Integer.parseInt(configuration.getOrCreateIntProperty("Goblin Miner Spawner Delay ", Configuration.CATEGORY_GENERAL, 180).value );

                VillageSpawnrate = Integer.parseInt(configuration.getOrCreateIntProperty("Village Spawnrate ", Configuration.CATEGORY_GENERAL, 36).value );				

        configuration.save();
    }


    
    static int MobGSpawnerBlockID;
    static int MobGRSpawnerBlockID;
    static int MobGMSpawnerBlockID;
    static int VillageSpawnBlockID; 
    static int ETNTBlockID; 
    static int MTNTBlockID; 
    static int totemRBlockID; 
    static int totemBBlockID; 
    static int totemGBlockID; 
    static int totemYBlockID ;
static int gobDrumBlockID ;
static int gobStoneBlockID ;
static int gobSlabWoodBlockID ;

    static int swordFireShiftedIndex;
static int GoblinFleshShiftedIndex;
    static int bombShiftedIndex;
static int staffBlueShiftedIndex;
static int staffNatureShiftedIndex;
static int ShurikenShiftedIndex;
static int arrowGShiftedIndex;
static int arrowRShiftedIndex;
static int arrowYShiftedIndex;
static int crystalBShiftedIndex;
static int crystalRShiftedIndex;
static int crystalGShiftedIndex;
static int crystalYShiftedIndex;
static int powderRShiftedIndex;
static int powderBShiftedIndex;
static int powderYShiftedIndex;
static int powderGShiftedIndex;
static int katanaSwordShiftedIndex;
static int staffTeleportShiftedIndex;
static int staffLightningShiftedIndex;
static int ectoplasmShiftedIndex;
static int GoblinBowShiftedIndex;
   
    static int GoblinRandSpawnrate1;
static int GoblinRandSpawnrate2;
static int GoblinRandSpawnrate3;

    static int SpawnerRandSpawnrate1;
static int SpawnerRandSpawnrate2;
static int SpawnerRandSpawnrate3;

    static int VillageSpawnrate;
} 

Link to comment
Share on other sites

Not only is your variable naming horrible, your code placement is horrible.

Anyways Why are you initalizing everything in the static initalizer?

Move it to load or modsloaded like a good boy.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

You didn't have to reply. You could ignore my post and someone else would solve my problem. Instead, you chose not to solve my problem, but to write un-constructive critiscism about my code. And to top that off, you didn't solve the problem either. When I posted my problem on the minecraft forum, I got an immediate fix (I asked here first, because I thought people who go on this forum all use and know how to use Forge). I assume you just wanted to offend me for no reason.

 

I don't understand what inclined you to post this. Is it that I put my question in a wrong section, and you wanted to insult me because of that? Or are you a dick to everyone who has a problem? Now, if you wrote some constructive critiscism ("like, your variable naming is bad because x", instead of "it sucks because I said so"), I wouldn't care that much, because I would learn something new.

 

Also, why did you write : "Move it to load or modsloaded like a good boy." Just because you wrote some API, doesn't mean you are better than the people who have problems here.

 

Don't get me wrong, I don't want to start a flame war (I'm deleting my account after this, because I sure I won't get any support here). I just want you to realize that you are a dick.

Link to comment
Share on other sites

You didn't have to reply. You could ignore my post and someone else would solve my problem. Instead, you chose not to solve my problem, but to write un-constructive critiscism about my code. And to top that off, you didn't solve the problem either. When I posted my problem on the minecraft forum, I got an immediate fix (I asked here first, because I thought people who go on this forum all use and know how to use Forge). I assume you just wanted to offend me for no reason.

 

I don't understand what inclined you to post this. Is it that I put my question in a wrong section, and you wanted to insult me because of that? Or are you a dick to everyone who has a problem? Now, if you wrote some constructive critiscism ("like, your variable naming is bad because x", instead of "it sucks because I said so"), I wouldn't care that much, because I would learn something new.

 

Also, why did you write : "Move it to load or modsloaded like a good boy." Just because you wrote some API, doesn't mean you are better than the people who have problems here.

 

Don't get me wrong, I don't want to start a flame war (I'm deleting my account after this, because I sure I won't get any support here). I just want you to realize that you are a dick.

 

Someone doesn't have a thick skin.

 

His reply did tell you EXACTLY how to fix it - you were initialising the blocks before the ID's had even had chance to be read. He did solve your problem, you just chose to ignore that part just because you felt his tongue in cheek reply was insulting you.

Link to comment
Share on other sites

And this ladies and gentlemen is how you get banned!

Quit being a insufferable twat, as they said I DID help you and give you the answer.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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