I'm not commenting anything in the code, as it should be self explained.
Just follow the tutorials out there to add other items in the mod.
This is a basic config file tutorial I thought I would post since the only ones I've seen use MLProp.
This config file does not use MLProp and should be tailorable to any mod.
You won't be able to make and add some objects compared to Forge modding when you keep them cross-compatible but that is a small price to pay.
This is the same code that I use in my mods.
Use these tutorials with this template file and make your own mods. It works with both Modloader and Forge Modloader though special forge stuff includes are needed. Have fun doing this, because I'm not. But that is the fun of modding, learning how to do things.
I have almost no clue as to what I am doing, so if I can figure it out and get it to work for my own mod, then you should be able to do it too.
I will help you out if I can, but most likely I cannot help you if you can't figure it out.
This tutorial will create a config file in your mods folder to change the IDs.
You can use this config tutorial on items, blocks, etc. Even variables for armor, damage and ore spawn amounts.
You need a "yourItem.png" in your texture folder in the appropriate one.
Here is the code. I have copied and pasted it from the java file I had just recompiled so it works as is.
1.5.X and above:
package net.minecraft.src;
import java.util.Random;
import java.io.*;
import java.util.*;
import net.minecraft.client.Minecraft;
public class mod_yourMod extends BaseMod
{
public String getVersion()
{
return "MineCraft1.5.2__YourMod1.5.2r1";
}
public mod_yourMod()
{
readWriteProperties();
yourItem = new Item(yourItemID).setUnlocalizedName("yourItem");
ModLoader.addName(yourItem, "Your Item");
yourItem.setCreativeTab(CreativeTabs.tabMaterials);
}
public void readWriteProperties() {
Properties properties = new Properties();
try
{
File file = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/mods/yourMod.config").toString());
boolean flag = file.createNewFile();
if(flag)
{
FileOutputStream fileoutputstream = new FileOutputStream(file);
properties.setProperty("yourItemID", Integer.toString(1500));
properties.store(fileoutputstream, "Change the ID's to fix ID incompatibilities.");
fileoutputstream.close();
}
properties.load(new FileInputStream((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/mods/yourMod.config").toString()));
yourItemID = Integer.parseInt(properties.getProperty("yourItemID"));
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
yourItemID = 1500;
}
}
public static Item yourItem;
public static int yourItemID;
public void load()
{
}
}
1.4.X and below:
package net.minecraft.src;
import java.io.*;
import java.util.*;
import net.minecraft.client.Minecraft;
public class mod_yourMod extends BaseMod
{
public mod_yourMod()
{
readWriteProperties();
//* ADD YOUR ITEMS AND RECIPES HERE */
yourItem = (new BlockSand(yourItemID, ModLoader.addOverride("/terrain.png", "/yourItem.png"))).setHardness(0.3F).setLightValue(0.0F).setBlockName("yourItem").setRequiresSelfNotify().setCreativeTab(CreativeTabs.tabDecorations);
ModLoader.addName(yourItem, "Your Item");
ModLoader.addRecipe(new ItemStack(yourItem, 1), new Object[] {" S ", " S ", " S ", 'S', Item.stick});
}
public void readWriteProperties() {
Properties properties = new Properties();
try
{
//* The line below creates your config file */
File file = new File((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/mods/yourMod.config").toString());
boolean flag = file.createNewFile();
if(flag)
{
FileOutputStream fileoutputstream = new FileOutputStream(file);
//* The line below sets the default ID of your items your config file */
properties.setProperty("yourItemID", Integer.toString(234));
//* more items here */
properties.store(fileoutputstream, "Change the ID's to fix ID incompatibilities.");
fileoutputstream.close();
}
//* The line below reads your config file */
properties.load(new FileInputStream((new StringBuilder()).append(Minecraft.getMinecraftDir()).append("/mods/yourMod.config").toString()));
//* The line below adds your items to your config file */
yourItemID = Integer.parseInt(properties.getProperty("yourItemID"));
//* more items here */
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
//* This prints the default ID to the config file */
yourItemID = 234;
//* more items here */
}
}
public String getVersion() {
return "1.3.2";
}
//* this creates your items in the world */
public static Block yourItem;
public static int yourItemID;
public void load()
{
ModLoader.registerBlock(yourItem);
}
}
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
Update, works fine with 1.4.X versions of Minecraft.
Rollback Post to RevisionRollBack
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
This is a tutorial or rather a template of a mod file that uses a config file in the mods folder so the user can change the item and block numbers so they can make their mods more compatible with other peoples mods.
I use this same code in my mods and is rather easy for me to tailor into new mods.
I hope this clears up any confusion as to what this is.
I added "template" to the title to make it more clear.
Rollback Post to RevisionRollBack
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
If you want to, you can use my source freely for your own code.
Thank you, I'm glad I helped you. good work.
I'll add a link to your config in the main post.
Rollback Post to RevisionRollBack
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
I would be really really glad if you could help me
PS!: I have modified the base files so there are NO ERRORS shown in Eclipse. This Error only appears when I try to launch (The whole code is shown-error-less.)
-taa1taa
Gimme a bit. What did you change it the base file, just so I know what your trying to do, haven't looked at your code yet, watching hockey. I'm pretty sure I can help you do what you need.
EDIT:
Okay I'm still watching hockey and haven't actually tested it,but just by the error "NumberFormatException" something went wrong with the number it's trying to store.
Looking at your code I see what could have errored out.
Try changing this:
properties.setProperty("Village Generation Rate (1=Alot of Villages 2=Normal 3=Not So Much Villages):", Integer.toString(2));
to this: (This part is what writes to the file if it doesn't exist and needs the integer name)
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
Thanks for the help, that actually wasnt the problem but I found the problem itself. You have to delete the ReadWriteProperties(); . It starts up fine now, testing if it actually works.
EDIT: Working!
It loaded the config without the "ReadWriteProperties();"?
Rollback Post to RevisionRollBack
Check out my mods: Kinyoshi Mods (which includes Ancient Tree Root, Bone Ore, Chert Craft, Corn Nuts, Desert Cotton Plant, Desert Grund Plant, Desert Petrified Wood and misc tweaks).https://sites.google.com/site/kinyoshimods/
Just follow the tutorials out there to add other items in the mod.
This is a basic config file tutorial I thought I would post since the only ones I've seen use MLProp.
This config file does not use MLProp and should be tailorable to any mod.
RoboMats (More advanced expansion) Custom Config Loader for ModLoader.
Compile in MCP with Risugami's Modloader only to make it Modloader and Forge Modloader compatible.
If you compile in MCP with Forge Modloader it will not be cross-compatible.
You won't be able to make and add some objects compared to Forge modding when you keep them cross-compatible but that is a small price to pay.
This is the same code that I use in my mods.
Use these tutorials with this template file and make your own mods. It works with both Modloader and Forge Modloader though special forge stuff includes are needed. Have fun doing this, because I'm not. But that is the fun of modding, learning how to do things.
TUTORIALS: (1.5.2, older versions tutorials also available.)
Popgalops Beginner-Advanced Modloader Modding Tutorials
Wuppy29s Forge Modloader Modding Tutorials
Jbond98s Modloader Modding Tutorials
I have almost no clue as to what I am doing, so if I can figure it out and get it to work for my own mod, then you should be able to do it too.
I will help you out if I can, but most likely I cannot help you if you can't figure it out.
This tutorial will create a config file in your mods folder to change the IDs.
You can use this config tutorial on items, blocks, etc. Even variables for armor, damage and ore spawn amounts.
You need a "yourItem.png" in your texture folder in the appropriate one.
Here is the code. I have copied and pasted it from the java file I had just recompiled so it works as is.
1.5.X and above:
1.4.X and below:
Glad it was useful for you
This is a tutorial or rather a template of a mod file that uses a config file in the mods folder so the user can change the item and block numbers so they can make their mods more compatible with other peoples mods.
I use this same code in my mods and is rather easy for me to tailor into new mods.
I hope this clears up any confusion as to what this is.
I added "template" to the title to make it more clear.
Thank you, I'm glad I helped you. good work.
I'll add a link to your config in the main post.
Gimme a bit. What did you change it the base file, just so I know what your trying to do, haven't looked at your code yet, watching hockey. I'm pretty sure I can help you do what you need.
EDIT:
Okay I'm still watching hockey and haven't actually tested it,but just by the error "NumberFormatException" something went wrong with the number it's trying to store.
Looking at your code I see what could have errored out.
Try changing this:
to this: (This part is what writes to the file if it doesn't exist and needs the integer name)
You can have the use instructions using the "fileoutputstream" part by changing:
to this:
That should work, hockey is in OT so I can't really test at the moment.
It loaded the config without the "ReadWriteProperties();"?