Help Modding A new sword

Calling all programmers: your mods go here!

Post Permalink
by ChazHaz » 9/19/2012

Hello

i am having some slight problems with my mod...
I do have modloader, eclpise and mcp.
I followed several tutorials but I still can't get my sword to work???
I get no errors no nothing just that i can't craft give myself the sword and can't get it in game. :x

Here is the code for sword
Spoiler
package net.minecraft.src;
import java.util.Random;

public class Mod_DofusMod extends BaseMod
{
public static final Item NetherrackSword = (new ItemSword(2001, EnumToolMaterial.NETHERRACK).setItemName("Neth"));

public void load()
{
NetherrackSword.iconIndex = ModLoader.addOverride("/gui/items.png" , "/Dofus_Items/NetherrackSword.png");
ModLoader.addName("NetherrackSword", "Netherrack Sword" );
ModLoader.addRecipe(new ItemStack(NetherrackSword,1), new Object[]
{
" & ", " & ", " X ",
'&', Block.netherrack, 'X', Item.stick
});

}



public String getVersion()
{
return "1";
}

}


Here is the enumtool file

Spoiler
package net.minecraft.src;

public enum EnumToolMaterial
{
WOOD(0, 59, 2.0F, 0, 15),
STONE(1, 131, 4.0F, 1, 5),
IRON(2, 250, 6.0F, 2, 14),
EMERALD(3, 1561, 8.0F, 3, 10),
GOLD(0, 32, 12.0F, 0, 22),
NETHERRACK(1, 120, 3.0F, 1, 5);

/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
private final int harvestLevel;

/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
private final int maxUses;

/**
* The strength of this tool material against blocks which it is effective against.
*/
private final float efficiencyOnProperMaterial;

/** Damage versus entities. */
private final int damageVsEntity;

/** Defines the natural enchantability factor of the material. */
private final int enchantability;

private EnumToolMaterial(int par3, int par4, float par5, int par6, int par7)
{
this.harvestLevel = par3;
this.maxUses = par4;
this.efficiencyOnProperMaterial = par5;
this.damageVsEntity = par6;
this.enchantability = par7;
}

/**
* The number of uses this material allows. (wood = 59, stone = 131, iron = 250, diamond = 1561, gold = 32)
*/
public int getMaxUses()
{
return this.maxUses;
}

/**
* The strength of this tool material against blocks which it is effective against.
*/
public float getEfficiencyOnProperMaterial()
{
return this.efficiencyOnProperMaterial;
}

/**
* Damage versus entities.
*/
public int getDamageVsEntity()
{
return this.damageVsEntity;
}

/**
* The level of material this tool can harvest (3 = DIAMOND, 2 = IRON, 1 = STONE, 0 = IRON/GOLD)
*/
public int getHarvestLevel()
{
return this.harvestLevel;
}

/**
* Return the natural enchantability factor of the material.
*/
public int getEnchantability()
{
return this.enchantability;
}
}


If someone can help me that would be great..
User avatar
Level 1
New Miner
Posts: 10
Joined: 7/27/12

Post Permalink
by sed11 » 9/19/2012

You can make a separate EnumToolMaterial for your sword so you won't have to edit base code, but I don't think that's a problem.

The problem is your crafting code.

You should put something like this after the letter things, for example:

Character.valueOf('X'), Item.stick

So it would be:
Spoiler
ModLoader.addRecipe(new ItemStack(NetherrackSword,1), new Object[]
{
" & ", " & ", " X ",
Character.valueOf('&'), Block.netherrack, Character.valueOf('X'), Item.stick
});
Image

Image

Image

Image

Image

Creepers gonna Creep!
User avatar
Forum Moderator
Level 57
Grandmaster Creeper
Posts: 6601
Joined: 7/9/11
Minecraft: cjw12

Post Permalink
by wolfgang798 » 9/19/2012

I have a video on making one it can be found here if u want something to watch http://www.planetminecraft.com/blog/how ... dding-132/
Image
User avatar
Level 42
Master Necromancer
Posts: 60
Joined: 4/27/12
Minecraft: wolfgang1999
mc_server: bjw.zapto.org

Post Permalink
by ChazHaz » 9/20/2012

sed11 wrote:You can make a separate EnumToolMaterial for your sword so you won't have to edit base code, but I don't think that's a problem.

The problem is your crafting code.

You should put something like this after the letter things, for example:

Character.valueOf('X'), Item.stick

So it would be:
Spoiler
ModLoader.addRecipe(new ItemStack(NetherrackSword,1), new Object[]
{
" & ", " & ", " X ",
Character.valueOf('&'), Block.netherrack, Character.valueOf('X'), Item.stick
});

thanks for your.answers I WILL try this later and sorry but i have watched many videos I.just need someone to tell me what the exact problem is.
User avatar
Level 1
New Miner
Posts: 10
Joined: 7/27/12

Post Permalink
by ChazHaz » 9/20/2012

The other thing I forgot say is that I'm trying to craft my item in creative , does that change anything? :?:
Image
User avatar
Level 1
New Miner
Posts: 10
Joined: 7/27/12

Post Permalink
by wolfgang798 » 9/20/2012

This is what i use for crafting recipes

ModLoader.addRecipe(new ItemStack(mod_Bloodathon.End result, 1), new Object[]
{
"BBB", "OSO", "BBB", 'S', Item.beefCooked, 'O', mod_Bloodathon.Blood



(in this B equals enpty space)
Image
User avatar
Level 42
Master Necromancer
Posts: 60
Joined: 4/27/12
Minecraft: wolfgang1999
mc_server: bjw.zapto.org

Post Permalink
by Morecraft » 9/20/2012

You guys seem like you know what your doing. Can someone here make me a mod that has only a couple of items? Btw, i dont understand modding, but some coding, and it looks like u had too many spaces.
Image
User avatar
Level 16
Journeyman Architect
Posts: 99
Joined: 2/19/12
Says: Stay Crafted!
Minecraft: Matthew_Cohen

Post Permalink
by ChazHaz » 9/20/2012

Morecraft wrote:You guys seem like you know what your doing. Can someone here make me a mod that has only a couple of items? Btw, i dont understand modding, but some coding, and it looks like u had too many spaces.

Check Out My Mod it kind of does that with a theme (Dofus)+ Nether style items and more... If it ever works.
Last edited by ChazHaz on 9/20/2012, edited 1 time in total.
Image
User avatar
Level 1
New Miner
Posts: 10
Joined: 7/27/12

Post Permalink
by ChazHaz » 9/20/2012

Here is the code now... still not working and does it make a difference if i am testing with creative i also don't have the server files do i need those?
Spoiler
package net.minecraft.src;
import java.util.Random;

public class Mod_DofusMod extends BaseMod
{
public static final Item NetherrackSword = (new ItemSword(2001, EnumToolMaterial.NETHERRACK).setItemName("Neth"));

public void load()
{
NetherrackSword.iconIndex = ModLoader.addOverride("/gui/items.png" , "/Dofus_Items/NetherrackSword.png");
ModLoader.addName("NetherrackSword", "Netherrack Sword" );
ModLoader.addRecipe(new ItemStack(Mod_DofusMod.NetherrackSword,1), new Object[]
{
" & ", " & ", " X ",
Character.valueOf('&'), Block.netherrack, Character.valueOf('X'), Item.stick
});

}



public String getVersion()
{
return "Beta 0.01";
}

}


Tried giving myself the sword and i get an error saying that there is no such thing as item id 2001
Image
User avatar
Level 1
New Miner
Posts: 10
Joined: 7/27/12

Post Permalink
by nickfromgreek » 9/20/2012

sed11 wrote:You can make a separate EnumToolMaterial for your sword so you won't have to edit base code, but I don't think that's a problem.

The problem is your crafting code.

You should put something like this after the letter things, for example:

Character.valueOf('X'), Item.stick

So it would be:
Spoiler
ModLoader.addRecipe(new ItemStack(NetherrackSword,1), new Object[]
{
" & ", " & ", " X ",
Character.valueOf('&'), Block.netherrack, Character.valueOf('X'), Item.stick
});



NONONONOONONO that makes it ALOT more complicated
User avatar
Level 24
Expert Modder
Posts: 314
Joined: 11/15/11
Says: Full time java coder,Modder,C++ app developer... if you need me feel free to shoot me a PM :)
Minecraft: Nickfromgreek
mc_server: VilleCraft

Post Permalink
by nickfromgreek » 9/20/2012

ChazHaz wrote:Here is the code now... still not working and does it make a difference if i am testing with creative i also don't have the server files do i need those?
Spoiler
package net.minecraft.src;
import java.util.Random;

public class Mod_DofusMod extends BaseMod
{
public static final Item NetherrackSword = (new ItemSword(2001, EnumToolMaterial.NETHERRACK).setItemName("Neth"));

public void load()
{
NetherrackSword.iconIndex = ModLoader.addOverride("/gui/items.png" , "/Dofus_Items/NetherrackSword.png");
ModLoader.addName("NetherrackSword", "Netherrack Sword" );
ModLoader.addRecipe(new ItemStack(Mod_DofusMod.NetherrackSword,1), new Object[]
{
" & ", " & ", " X ",
Character.valueOf('&'), Block.netherrack, Character.valueOf('X'), Item.stick
});

}



public String getVersion()
{
return "Beta 0.01";
}

}


Tried giving myself the sword and i get an error saying that there is no such thing as item id 2001



error 1 change this

ModLoader.addName("NetherrackSword", "Netherrack Sword" );

to this

ModLoader.addName( NetherrackSword , "Netherrack Sword" );
User avatar
Level 24
Expert Modder
Posts: 314
Joined: 11/15/11
Says: Full time java coder,Modder,C++ app developer... if you need me feel free to shoot me a PM :)
Minecraft: Nickfromgreek
mc_server: VilleCraft

Post Permalink
by nickfromgreek » 9/20/2012

AANND FINALY GOT TEH ERROR!!!!!!!!!!!!

change this:
public static final Item NetherrackSword = (new ItemSword(2001, EnumToolMaterial.NETHERRACK).setItemName("Neth"));

to this

public static final Item NetherrackSword = (new ItemSword(2001, EnumToolMaterial.NETHERRACK).setItemName("Neth")
User avatar
Level 24
Expert Modder
Posts: 314
Joined: 11/15/11
Says: Full time java coder,Modder,C++ app developer... if you need me feel free to shoot me a PM :)
Minecraft: Nickfromgreek
mc_server: VilleCraft

Next

Return to Modding