MC Modding
Please register and join the community!

[1.8.1] Generating Properties File

View previous topic View next topic Go down

[1.8.1] Generating Properties File

Post by Strengthowns on Wed Oct 05, 2011 10:53 am

Generating Properties File

Spoiler:
mod_Namehere
Code:
package net.minecraft.src;

import java.io.*;
import java.util.Map;
import java.util.Random;
import net.minecraft.client.Minecraft;

public class mod_Namehere extends BaseMod
{

    public mod_Namehere()
    {
        NamehereProperties namehereproperties = new NamehereProperties();
        try
        {
            File file = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/Namehere.properties").toString());
            boolean flag = file.createNewFile();
            if(flag)
            {
                FileOutputStream fileoutputstream = new FileOutputStream(file);
                namehereproperties.setProperty("idNamehere", Integer.toString(defaultNamehere));
                namehereproperties.store(fileoutputstream, "fglkjdgflgksdf");
                fileoutputstream.close();
            }
            namehereproperties.load(new FileInputStream((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/Namehere.properties").toString()));
            idNamehere = Integer.parseInt(namehereproperties.getProperty("idNamehere"));
        }
        catch(IOException ioexception)
        {
            ioexception.printStackTrace();
        }
        Block Namehere = (new BlockNamehere(idNamehere, 0)).setLightValue(1.0F).setHardness(3F).setResistance(0F).setBlockName("Namehere");
        ModLoader.RegisterBlock(Namehere);
        Namehere.blockIndexInTexture = ModLoader.addOverride("/terrain.png", "/Namehere.png");   
        ModLoader.AddName(Namehere, "Namehere");
        ModLoader.AddRecipe(new ItemStack(Namehere, 1), new Object[] {
            "XXX", "XXX", "XXX", Character.valueOf('X'), Block.dirt
        });
    }

    public String Version()
    {
        return "1.7.3";
    }

    public static Block Namehere;
    public static int idNamehere;
    public static int defaultNamehere = 109;
}

BlockNamehere
Code:
package net.minecraft.src;

import java.util.Random;

public class BlockNamehere extends Block
{

    protected BlockNamehere(int i, int j)
    {
        super(i, j, Material.ground);
    }

    public int idDropped(int i, Random random)
    {
        return mod_Namehere.Namehere.blockID;
    }
}

NamehereProperties
Code:
package net.minecraft.src;

import java.util.*;

public class NamehereProperties extends Properties
{

    public NamehereProperties()
    {
    }

    public synchronized Enumeration keys()
    {
        Enumeration enumeration = super.keys();
        Vector vector = new Vector();
        for(; enumeration.hasMoreElements(); vector.add(enumeration.nextElement())) { }
        Collections.sort(vector);
        return vector.elements();
    }
}

Help: mod_Namehere

1. Some of the stuff at the very top I don't think you need but it doesn't matter.

2. At the but that says this:
Code:
File file = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/Namehere.properties").toString());
for the ("/Namehere.properties") This is where you will find the generated properties file. So in this case it will just be in the .minecraft folder.

3. Keep changing the Namehere's up until this bit:
Code:
namehereproperties.store(fileoutputstream, "fglkjdgflgksdf");
you change the namehere at the start of it and the random jumble of letters is what it will say in the properties file if you wanted to put a message in.

4. Keep changing all the Namehere's and... recompile + reob. Mod your minecraft, start the game, close it and have a look in .minecraft! There is your properties file!! Yay!

Help: BlockNamehere

1. Same as normal...

Help: NamehereProperties

1. Leave everything here except for changing the Namehere's.
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Generating Properties File

Post by apotato on Wed Nov 16, 2011 12:19 pm

I did all this, but when I tried to make a new id, it crashed...

apotato
Member

Posts : 2
Join date : 2011-11-16

View user profile

Back to top Go down

Re: [1.8.1] Generating Properties File

Post by groxmapper on Thu Nov 17, 2011 1:46 am

apotato wrote:I did all this, but when I tried to make a new id, it crashed...

Same. I can get it to make a properties files by initializing the ID variable first, but it won't read from it to assign IDs.
avatar
groxmapper
Member

Posts : 27
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Generating Properties File

Post by apotato on Fri Nov 18, 2011 7:38 am

Don't worry, I fixed it!

apotato
Member

Posts : 2
Join date : 2011-11-16

View user profile

Back to top Go down

Re: [1.8.1] Generating Properties File

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum