[1.8.1] Generating Properties File
3 posters
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
[1.8.1] Generating Properties File
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());
3. Keep changing the Namehere's up until this bit:- Code:
namehereproperties.store(fileoutputstream, "fglkjdgflgksdf");
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.
Re: [1.8.1] Generating Properties File
I did all this, but when I tried to make a new id, it crashed...
apotato- Member
- Posts : 2
Join date : 2011-11-16
Re: [1.8.1] Generating Properties File
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.
groxmapper- Member
- Posts : 27
Join date : 2011-10-24
Re: [1.8.1] Generating Properties File
Don't worry, I fixed it!
apotato- Member
- Posts : 2
Join date : 2011-11-16
Similar topics
» [1.8.1] Generating Ores
» [Answered]Problem with ore generating
» [Answered] Help with generating ores
» [Answered]Problem with ore generating
» [Answered] Help with generating ores
MC Modding :: Modding :: Singleplayer Modding :: Tutorials
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum