MC Modding
Please register and join the community!

[UnAnswered]Tool Error.

MC Modding :: Help :: Help

View previous topic View next topic Go down

[UnAnswered]Tool Error.

Post by breakyorself on Mon Oct 24, 2011 4:41 am

I tried making tools:
Code:
package net.minecraft.src;
import java.util.Random;

public class mod_Obsidian extends BaseMod
{

public static final Item Pick = new ItemPickaxe(2001, EnumToolMaterial.EMERALD).setItemName("Obsidian Pickaxe");
public static final Item Spade = new ItemSpade(2002, EnumToolMaterial.EMERALD).setItemName("Obsidian Spade");
public static final Item Axe = new ItemAxe(2003, EnumToolMaterial.EMERALD).setItemName("Obsidian Axe");
public static final Item Hoe = new ItemHoe(2004, EnumToolMaterial.EMERALD).setItemName("Obsidian Hoe");
public static final Item Sword = new ItemSword(2005, EnumToolMaterial.EMERALD).setItemName("Obsidian Hoe");

public mod_Obsidian()
{

Pick.iconIndex = ModLoader.addOverride("/gui/items.png", "/obsidian/Pick.png");
Spade.iconIndex = ModLoader.addOverride("/gui/items.png", "/obsidian/Spade.png");
Axe.iconIndex = ModLoader.addOverride("/gui/items.png", "/obsidian/Axe.png");
Hoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/obsidian/Hoe.png");
Sword.iconIndex = ModLoader.addOverride("/gui/items.png", "/obsidian/Sword.png");


ModLoader.AddName(Pick, "Pickaxe");
ModLoader.AddName(Spade, "Shovel");
ModLoader.AddName(Axe, "Axe");
ModLoader.AddName(Hoe, "Hoe");
ModLoader.AddName(Sword, "Sword");


ModLoader.AddRecipe(new ItemStack(Pick, 1), new Object[] {
"$$$", " * ", " * ", Character.valueOf('*'), Item.stick, Character.valueOf('$'), Block.obsidian
});
ModLoader.AddRecipe(new ItemStack(Axe, 1), new Object[] {
"** ", "*# ", " # ", Character.valueOf('*'), Block.obsidian, Character.valueOf('#'), Item.stick
});
ModLoader.AddRecipe(new ItemStack(Spade, 1), new Object[] {
"#", " * ", " * ", Character.valueOf('*'), Item.stick, Character.valueOf('#'), Block.obsidian
});
ModLoader.AddRecipe(new ItemStack(Hoe, 1), new Object[] {
"$$", " * ", " * ", Character.valueOf('*'), Item.stick, Character.valueOf('$'), Block.obsidian
});
ModLoader.AddRecipe(new ItemStack(Sword, 1), new Object[] {
" $ ", " $ ", " * ", Character.valueOf('*'), Item.stick, Character.valueOf('$'), Block.obsidian
});
}

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


Error report:
Spoiler:
java.lang.StringIndexOutOfBoundsException: String index out of range: 7
at java.lang.String.charAt(Unknown Source)
at net.minecraft.src.CraftingManager.addRecipe(CraftingManager.java:276)
at net.minecraft.src.ModLoader.AddRecipe(ModLoader.java:330)
at net.minecraft.src.mod_Obsidian.<init>(mod_Obsidian.java:39)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.minecraft.src.ModLoader.addMod(ModLoader.java:224)
at net.minecraft.src.ModLoader.readFromClassPath(ModLoader.java:1027)
at net.minecraft.src.ModLoader.init(ModLoader.java:692)
at net.minecraft.src.ModLoader.AddAllRenderers(ModLoader.java:121)
at net.minecraft.src.RenderManager.<init>(RenderManager.java:72)
at net.minecraft.src.RenderManager.<clinit>(RenderManager.java:168)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:140)
at net.minecraft.client.Minecraft.run(Minecraft.java:438)
at java.lang.Thread.run(Unknown Source)
--- END ERROR REPORT 7ebcc6c2 ----------
avatar
breakyorself
Member

Posts : 60
Join date : 2011-10-19

View user profile

Back to top Go down

Re: [UnAnswered]Tool Error.

Post by filip151 on Tue Oct 25, 2011 5:21 pm

hmm, maybe I can help you use my code
Code:
package net.minecraft.src;

import java.util.Random;

public class mod_Bronzetools extends BaseMod
{
  public static final Item Bronzepick = new ItemPickaxe(1000, EnumToolMaterial.BRONZE).setItemName("Bronzepick");
  public static final Item Bronzeshovel = new ItemSpade(1001, EnumToolMaterial.BRONZE).setItemName("Bronzeshovel");
  public static final Item Bronzeaxe = new ItemAxe(1002, EnumToolMaterial.BRONZE).setItemName("Bronzeaxe");
  public static final Item Bronzehoe = new ItemHoe(1003, EnumToolMaterial.BRONZE).setItemName("Bronzehoe");
  public static final Item Bronzesword = new ItemSword(1004, EnumToolMaterial.BRONZE).setItemName("Bronzesword");
     
public mod_Bronzetools()
{

               
        //Textures
       Bronzepick.iconIndex = ModLoader.addOverride("/gui/items.png", "/Textur/pick1.png");
       Bronzeshovel.iconIndex = ModLoader.addOverride("/gui/items.png", "/Textur/spade1.png");
       Bronzeaxe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Textur/axe1.png");
       Bronzehoe.iconIndex = ModLoader.addOverride("/gui/items.png", "/Textur/hoe1.png");
       Bronzesword.iconIndex = ModLoader.addOverride("/gui/items.png", "/Textur/sword1.png");
 
        //In Game Names
  ModLoader.AddName(Bronzepick, "Bronze Pickaxe");
  ModLoader.AddName(Bronzeshovel, "Bronze Shovel");
  ModLoader.AddName(Bronzeaxe, "Bronze Axe");
  ModLoader.AddName(Bronzehoe, "Bronze Hoe");
  ModLoader.AddName(Bronzesword, "Bronze Sword");
 
        //Recipes
  ModLoader.AddRecipe(new ItemStack(Bronzepick, 1), new Object[] {
            "XXX", " | ", " | ", Character.valueOf('X'), mod_Bronzeingot.Bronzeingot, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(Bronzeshovel, 1), new Object[] {
            " X ", " | ", " | ", Character.valueOf('X'), mod_Bronzeingot.Bronzeingot, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(Bronzeaxe, 1), new Object[] {
            "XX ", "X| ", " | ", Character.valueOf('X'), mod_Bronzeingot.Bronzeingot, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(Bronzehoe, 1), new Object[] {
            "XX ", " | ", " | ", Character.valueOf('X'), mod_Bronzeingot.Bronzeingot, Character.valueOf('|'), Item.stick
        });
  ModLoader.AddRecipe(new ItemStack(Bronzesword, 1), new Object[] {
            " X ", " X ", " | ", Character.valueOf('X'), mod_Bronzeingot.Bronzeingot, Character.valueOf('|'), Item.stick
        });
  }
     


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

}
then just change the EnumToolMatereial.BRONZE to EnumToolMatereial.EMERALD and all the names to yours, then it should work! If you still get the error, then I don't know.

filip151
Member

Posts : 11
Join date : 2011-10-21
Age : 18
Location : Norway, Oslo Poland, Swiecie

View user profile

Back to top Go down

Re: [UnAnswered]Tool Error.

Post by breakyorself on Wed Oct 26, 2011 1:39 am

I know the enumtoolmaterial and i created my own material.
avatar
breakyorself
Member

Posts : 60
Join date : 2011-10-19

View user profile

Back to top Go down

Re: [UnAnswered]Tool Error.

Post by lildudemike on Mon Dec 05, 2011 4:38 am

You need to personalize it more with more files. Instead of
public static final Item Pick = new ItemPickaxe
it should be
public static final emeraldPickaxe = new ItemPickaxeEmerald

Then you will need to create a file called ItemPickaxeEmerald and copy the code from ItemPickaxe into it, replace ItemPickaxe with ItemPickaxeEmerald and enjoy. Smile

or if you don't need it to be so personalized you could just do

public static final Item emeraldPickaxe = new ItemPickaxe


Last edited by lildudemike on Mon Dec 05, 2011 4:40 am; edited 1 time in total (Reason for editing : didn't realize that it didn't have to be that personalized)

lildudemike
Member

Posts : 2
Join date : 2011-12-04

View user profile

Back to top Go down

Re: [UnAnswered]Tool Error.

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


MC Modding :: Help :: Help

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