Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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.

Posted

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.

Posted

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

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • the modpack keep crashing idk why,cause it never said anything about any mods causing it. crash log:https://drive.google.com/file/d/1iYKlUgvHUob8DjyRc3gqP_Viv_kSHO6L/view?usp=sharing mod list:https://drive.google.com/file/d/1MvMT-z9Jg2BITQ4uLshJ1uOh7q9EMBfC/view?usp=sharing but the server(anternos) works just fine
    • Hello, I am trying to make 2 recipes for a ruby. The first one is turning a block into a ruby and the other one is 9 nuggets into a ruby. But I keep on getting a error java.lang.IllegalStateException: Duplicate recipe rubymod:ruby   Any help would be great on how to fix it
    • Hello everyone, i'm new with programing Mods, and will need a lot of your help if possible,  Im trying to make a new GUI interface responsible to control the Droprate of game, it will control de loot drop and loot table for mobs and even blocks, but i try to make a simple Gui Screen, and wenever i try to use it, the game crash's with the error message in the subject, here is the code im using to:  IDE: IntelliJ Comunity - latest version Forge: 47.3.0 Minecraft version: 1.20.1 mapping_channel: parchment mapping_version=2023.09.03-1.20.1 Crash report link: https://pastebin.com/6dV8k1Fw   Code im using is:    package createchronical.droprateconfig; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import java.util.HashMap; import java.util.Map; public class ConfigScreen extends Screen { private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("droprateconfig", "textures/gui/config_background.png"); // Mapa de mobs e itens com seus respectivos drop rates private final Map<String, Integer> dropRates = new HashMap<>(); public ConfigScreen() { super(Component.literal("Configurações de Drop Rate")); // Inicializa com valores de drop rate padrão dropRates.put("Zombie", 10); // Exemplo de mob dropRates.put("Creeper", 5); // Exemplo de mob dropRates.put("Iron Ore", 50); // Exemplo de item dropRates.put("Diamond", 2); // Exemplo de item } @Override protected void init() { // Cria um botão para cada mob/item e adiciona na tela int yOffset = this.height / 2 - 100; // Posicionamento inicial for (Map.Entry<String, Integer> entry : dropRates.entrySet()) { String itemName = entry.getKey(); int dropRate = entry.getValue(); // Cria um botão para cada mob/item this.addRenderableWidget(Button.builder( Component.literal(itemName + ": " + dropRate + "%"), button -> onDropRateButtonPressed(itemName) ).bounds(this.width / 2 - 100, yOffset, 200, 20).build()); yOffset += 25; // Incrementa a posição Y para o próximo botão } // Adiciona o botão de "Salvar Configurações" this.addRenderableWidget(Button.builder(Component.literal("Salvar Configurações"), button -> onSavePressed()) .bounds(this.width / 2 - 100, yOffset, 200, 20) .build()); } private void onDropRateButtonPressed(String itemName) { // Lógica para alterar o drop rate do item/mob selecionado // Aqui, vamos apenas incrementar o valor como exemplo int currentRate = dropRates.get(itemName); dropRates.put(itemName, currentRate + 5); // Aumenta o drop rate em 5% } private void onSavePressed() { // Lógica para salvar as configurações (temporariamente apenas na memória) // Vamos apenas imprimir para verificar dropRates.forEach((item, rate) -> { System.out.println("Item: " + item + " | Novo Drop Rate: " + rate + "%"); }); // Fecha a tela após salvar Screen pGuiScreen = null; assert this.minecraft != null; this.minecraft.setScreen(pGuiScreen); } @Override public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) { this.renderBackground(guiGraphics); guiGraphics.blit(BACKGROUND_TEXTURE, this.width / 2 - 128, this.height / 2 - 128, 0, 0, 256, 256, 256, 256); super.render(guiGraphics, mouseX, mouseY, partialTicks); } }  
  • Topics

×
×
  • Create New...

Important Information

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