For all you javascripters/modders out there, I have a question that may come simple to you.
How do I make a Sword/Item created deal damage?
I would like my Emerald Sword to deal 8 hearts of damage.
If you know what the code is, please leave a comment in reply.
Thanks! :smile.gif:
For all you javascripters/modders out there, I have a question that may come simple to you.
How do I make a Sword/Item created deal damage?
I would like my Emerald Sword to deal 8 hearts of damage.
If you know what the code is, please leave a comment in reply.
Thanks! :smile.gif:
When you made the Enum(Tool/sword/whateveryoucalledit).java (I'm guessing you did) You would have set a weaponDamage value, which would correspond with the equation listed in the ItemSword.java
It would use this equation, plus the value you have set for enumtoolmaterial in your Enum(Tool/sword/whateveryoucalledit).java x2 to determine the value of damage done on an enemy (i believe the values are in half hearts)
When you made the Enum(Tool/sword/whateveryoucalledit).java (I'm guessing you did) You would have set a weaponDamage value, which would correspond with the equation listed in the ItemSword.java
It would use this equation, plus the value you have set for enumtoolmaterial in your Enum(Tool/sword/whateveryoucalledit).java x2 to determine the value of damage done on an enemy (i believe the values are in half hearts)
Tell me what I should fix/add in the script used (Title: mod_EmSword.java)
package net.minecraft.src;
import java.util.Random;
public class mod_EmSword extends BaseMod
{
public static final Item ESword = new SwordItem(5803).setItemName("ESItemName");
public mod_EmSword()
{
ESword.iconIndex = ModLoader.addOverride("/gui/items.png","/CoolMod/EmraldSword.png");
ModLoader.AddName(ESword, "Emerald Sword");
ModLoader.AddRecipe(new ItemStack(ESword, 1), new Object []{
" E "," E "," S ", Character.valueOf('E'), mod_EmItem.EItem, Character.valueOf('S'), Item.stick
});
}
public String Version()
{
return "3.14159265";
}
}
Next, I have the item code (Title: SwordItem.java):
package net.minecraft.src;
public class SwordItem extends Item
{
public SwordItem (int i)
{
super(i);
maxStackSize = 1;
}
}
When you made the Enum(Tool/sword/whateveryoucalledit).java (I'm guessing you did) You would have set a weaponDamage value, which would correspond with the equation listed in the ItemSword.java
It would use this equation, plus the value you have set for enumtoolmaterial in your Enum(Tool/sword/whateveryoucalledit).java x2 to determine the value of damage done on an enemy (i believe the values are in half hearts)
This is what I used in the ITEM java. (SwordItem.java, my Emerald Sword code.)
weaponDamage = 16 + enumtoolmaterial.getDamageVsEntity() * 2;
I changed 4 to 16. Is that the problem of me getting 2 errors in recompile?
Tell me what I should fix/add in the script used (Title: mod_EmSword.java)
package net.minecraft.src;
import java.util.Random;
public class mod_EmSword extends BaseMod
{
public static final Item ESword = new SwordItem(5803).setItemName("ESItemName");
public mod_EmSword()
{
ESword.iconIndex = ModLoader.addOverride("/gui/items.png","/CoolMod/EmraldSword.png");
ModLoader.AddName(ESword, "Emerald Sword");
ModLoader.AddRecipe(new ItemStack(ESword, 1), new Object []{
" E "," E "," S ", Character.valueOf('E'), mod_EmItem.EItem, Character.valueOf('S'), Item.stick
});
}
public String Version()
{
return "3.14159265";
}
}
Next, I have the item code (Title: SwordItem.java):
package net.minecraft.src;
public class SwordItem extends Item
{
public SwordItem (int i)
{
super(i);
maxStackSize = 1;
}
}
What should I add or fix? :dry.gif:
You need to make another .java file for the material, like the EnumToolMaterial.java, defining the new materials values just as the Vanillas materials are defined here:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
public enum EnumToolMaterial
{
WOOD("WOOD", 0, 0, 59, 2.0F, 0),
STONE("STONE", 1, 1, 131, 4F, 1),
IRON("IRON", 2, 2, 250, 6F, 2),
EMERALD("EMERALD", 3, 3, 1561, 8F, 3),
GOLD("GOLD", 4, 0, 32, 12F, 0);
/*
public static EnumToolMaterial[] values()
{
return (EnumToolMaterial[])allToolMaterials.clone();
}
public static EnumToolMaterial valueOf(String s)
{
return (EnumToolMaterial)Enum.valueOf(net.minecraft.src.EnumToolMaterial.class, s);
}
*/
private EnumToolMaterial(String s, int i, int j, int k, float f, int l)
{
harvestLevel = j;
maxUses = k;
efficiencyOnProperMaterial = f;
damageVsEntity = l;
}
public int getMaxUses()
{
return maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return damageVsEntity;
}
public int getHarvestLevel()
{
return harvestLevel;
}
/*
public static final EnumToolMaterial WOOD;
public static final EnumToolMaterial STONE;
public static final EnumToolMaterial IRON;
public static final EnumToolMaterial EMERALD;
public static final EnumToolMaterial GOLD;
*/
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
// private static final EnumToolMaterial allToolMaterials[]; /* synthetic field */
/*
static
{
WOOD = new EnumToolMaterial("WOOD", 0, 0, 59, 2.0F, 0);
STONE = new EnumToolMaterial("STONE", 1, 1, 131, 4F, 1);
IRON = new EnumToolMaterial("IRON", 2, 2, 250, 6F, 2);
EMERALD = new EnumToolMaterial("EMERALD", 3, 3, 1561, 8F, 3);
GOLD = new EnumToolMaterial("GOLD", 4, 0, 32, 12F, 0);
allToolMaterials = (new EnumToolMaterial[] {
WOOD, STONE, IRON, EMERALD, GOLD
});
}
*/
}
You need to make another .java file for the material, like the EnumToolMaterial.java, defining the new materials values just as the Vanillas materials are defined here:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
public enum EnumToolMaterial
{
WOOD("WOOD", 0, 0, 59, 2.0F, 0),
STONE("STONE", 1, 1, 131, 4F, 1),
IRON("IRON", 2, 2, 250, 6F, 2),
EMERALD("EMERALD", 3, 3, 1561, 8F, 3),
GOLD("GOLD", 4, 0, 32, 12F, 0);
/*
public static EnumToolMaterial[] values()
{
return (EnumToolMaterial[])allToolMaterials.clone();
}
public static EnumToolMaterial valueOf(String s)
{
return (EnumToolMaterial)Enum.valueOf(net.minecraft.src.EnumToolMaterial.class, s);
}
*/
private EnumToolMaterial(String s, int i, int j, int k, float f, int l)
{
harvestLevel = j;
maxUses = k;
efficiencyOnProperMaterial = f;
damageVsEntity = l;
}
public int getMaxUses()
{
return maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return damageVsEntity;
}
public int getHarvestLevel()
{
return harvestLevel;
}
/*
public static final EnumToolMaterial WOOD;
public static final EnumToolMaterial STONE;
public static final EnumToolMaterial IRON;
public static final EnumToolMaterial EMERALD;
public static final EnumToolMaterial GOLD;
*/
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
// private static final EnumToolMaterial allToolMaterials[]; /* synthetic field */
/*
static
{
WOOD = new EnumToolMaterial("WOOD", 0, 0, 59, 2.0F, 0);
STONE = new EnumToolMaterial("STONE", 1, 1, 131, 4F, 1);
IRON = new EnumToolMaterial("IRON", 2, 2, 250, 6F, 2);
EMERALD = new EnumToolMaterial("EMERALD", 3, 3, 1561, 8F, 3);
GOLD = new EnumToolMaterial("GOLD", 4, 0, 32, 12F, 0);
allToolMaterials = (new EnumToolMaterial[] {
WOOD, STONE, IRON, EMERALD, GOLD
});
}
*/
}
This is where if you defined lets say, with diamonds value(Stated as Emerald) is 3, the values would plugin like:
weaponDamage = 4 + 3(from diamond value) * 2;
Doing a grand total of 14 half hearts, 7 hearts damage (that value seems wrong for some reason :/)
Notice, this is where the equation calls for this section:
At the top of the ItemTool.java, it states:
protected ItemTool(int i, int j, EnumToolMaterial enumtoolmaterial, Block ablock[])
So that whenever enumtoolmaterial is used, it calls EnumToolMaterial, which is defined in:
private EnumToolMaterial(String s, int i, int j, int k, float f, int l)
You should probably take another math class... 4 + 3 * 2 = 10, so 5 hearts of damage, which is correct for diamond swords. (You do multiplication FIRST, then add four)
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then. WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I used the EMERALD material, now it's giving me 1 error. :/
What's the error, bro?
Rollback Post to RevisionRollBack
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then. WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
You need to make another .java file for the material, like the EnumToolMaterial.java, defining the new materials values just as the Vanillas materials are defined here:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
public enum EnumToolMaterial
{
WOOD("WOOD", 0, 0, 59, 2.0F, 0),
STONE("STONE", 1, 1, 131, 4F, 1),
IRON("IRON", 2, 2, 250, 6F, 2),
EMERALD("EMERALD", 3, 3, 1561, 8F, 3),
GOLD("GOLD", 4, 0, 32, 12F, 0);
/*
public static EnumToolMaterial[] values()
{
return (EnumToolMaterial[])allToolMaterials.clone();
}
public static EnumToolMaterial valueOf(String s)
{
return (EnumToolMaterial)Enum.valueOf(net.minecraft.src.EnumToolMaterial.class, s);
}
*/
private EnumToolMaterial(String s, int i, int j, int k, float f, int l)
{
harvestLevel = j;
maxUses = k;
efficiencyOnProperMaterial = f;
damageVsEntity = l;
}
public int getMaxUses()
{
return maxUses;
}
public float getEfficiencyOnProperMaterial()
{
return efficiencyOnProperMaterial;
}
public int getDamageVsEntity()
{
return damageVsEntity;
}
public int getHarvestLevel()
{
return harvestLevel;
}
/*
public static final EnumToolMaterial WOOD;
public static final EnumToolMaterial STONE;
public static final EnumToolMaterial IRON;
public static final EnumToolMaterial EMERALD;
public static final EnumToolMaterial GOLD;
*/
private final int harvestLevel;
private final int maxUses;
private final float efficiencyOnProperMaterial;
private final int damageVsEntity;
// private static final EnumToolMaterial allToolMaterials[]; /* synthetic field */
/*
static
{
WOOD = new EnumToolMaterial("WOOD", 0, 0, 59, 2.0F, 0);
STONE = new EnumToolMaterial("STONE", 1, 1, 131, 4F, 1);
IRON = new EnumToolMaterial("IRON", 2, 2, 250, 6F, 2);
EMERALD = new EnumToolMaterial("EMERALD", 3, 3, 1561, 8F, 3);
GOLD = new EnumToolMaterial("GOLD", 4, 0, 32, 12F, 0);
allToolMaterials = (new EnumToolMaterial[] {
WOOD, STONE, IRON, EMERALD, GOLD
});
}
*/
}
You should probably take another math class... 4 + 3 * 2 = 10, so 5 hearts of damage, which is correct for diamond swords. (You do multiplication FIRST, then add four)
Lol, forgot order of operations, sorry bro, people make stupid mistakes sometimes, no need to come out with such a judgemental statement as
I have seen this video, this is how I came to use the material "EMERALD".
It gave me an error that is not understandable to me. :sad.gif:
The error reads:
src\minecraft\net\minecraftsrc\mod_EmSword.java:6: cannot find symbol
symbol: constructor SwordItem(int,net.minecraft.src.EnumToolMaterial)
loaction: class net.minecraft.src.SwordItem
public static final Item ESword = new SwordItem(5803,EnumToolMaterial.EMERALD).setItemName("ESName");
I have seen this video, this is how I came to use the material "EMERALD".
It gave me an error that is not understandable to me. :sad.gif:
The error reads:
src\minecraft\net\minecraftsrc\mod_EmSword.java:6: cannot find symbol
symbol: constructor SwordItem(int,net.minecraft.src.EnumToolMaterial)
loaction: class net.minecraft.src.SwordItem
public static final Item ESword = new SwordItem(5803,EnumToolMaterial.EMERALD).setItemName("ESName");
Its because your using the custom file you made for the sword :/ Change SwordItem to ItemSword.
How do I make a Sword/Item created deal damage?
I would like my Emerald Sword to deal 8 hearts of damage.
If you know what the code is, please leave a comment in reply.
Thanks! :smile.gif:
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
When you made the Enum(Tool/sword/whateveryoucalledit).java (I'm guessing you did) You would have set a weaponDamage value, which would correspond with the equation listed in the ItemSword.java
It would use this equation, plus the value you have set for enumtoolmaterial in your Enum(Tool/sword/whateveryoucalledit).java x2 to determine the value of damage done on an enemy (i believe the values are in half hearts)
Tell me what I should fix/add in the script used (Title: mod_EmSword.java)
package net.minecraft.src;
import java.util.Random;
public class mod_EmSword extends BaseMod
{
public static final Item ESword = new SwordItem(5803).setItemName("ESItemName");
public mod_EmSword()
{
ESword.iconIndex = ModLoader.addOverride("/gui/items.png","/CoolMod/EmraldSword.png");
ModLoader.AddName(ESword, "Emerald Sword");
ModLoader.AddRecipe(new ItemStack(ESword, 1), new Object []{
" E "," E "," S ", Character.valueOf('E'), mod_EmItem.EItem, Character.valueOf('S'), Item.stick
});
}
public String Version()
{
return "3.14159265";
}
}
Next, I have the item code (Title: SwordItem.java):
package net.minecraft.src;
public class SwordItem extends Item
{
public SwordItem (int i)
{
super(i);
maxStackSize = 1;
}
}
What should I add or fix? :dry.gif:
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
This is what I used in the ITEM java. (SwordItem.java, my Emerald Sword code.)
weaponDamage = 16 + enumtoolmaterial.getDamageVsEntity() * 2;
I changed 4 to 16. Is that the problem of me getting 2 errors in recompile?
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
You need to make another .java file for the material, like the EnumToolMaterial.java, defining the new materials values just as the Vanillas materials are defined here:
The values for each material are listed here:
Coinciding with the variables stated in:
This is where if you defined lets say, with diamonds value(Stated as Emerald) is 3, the values would plugin like:
Doing a grand total of 14 half hearts, 7 hearts damage (that value seems wrong for some reason :/)
Notice, this is where the equation calls for this section:
At the top of the ItemTool.java, it states:
So that whenever enumtoolmaterial is used, it calls EnumToolMaterial, which is defined in:
Does it have to be this hard? I'm a starter, and I don't know this :/
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
I know exactly how you feel bro, I only started modding on the 20th
I think its best for you to take modding tuts from RandomAnimator101 on youtube
He goes into depth about blocks, tools, armor, and much more
Thanks, I'll take a look at his channel. :smile.gif:
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
I looked at most of his Tutorials, I don't see a video on sword making. :sad.gif:
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
You should probably take another math class... 4 + 3 * 2 = 10, so 5 hearts of damage, which is correct for diamond swords. (You do multiplication FIRST, then add four)
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then.
WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I used the EMERALD material, now it's giving me 1 error. :/
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
What's the error, bro?
I had a mod back in Beta 1.8.1, but I quit for a while so it hasn't been updated since then.
WTF <-- If you'd like to try and update it, let me know. (It won't be an easy task, I'm sure)
I used the material "EMERALD" (diamond material,) and it gave me an error. :L
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
Lol, forgot order of operations, sorry bro, people make stupid mistakes sometimes, no need to come out with such a judgemental statement as
I have seen this video, this is how I came to use the material "EMERALD".
It gave me an error that is not understandable to me. :sad.gif:
The error reads:
src\minecraft\net\minecraftsrc\mod_EmSword.java:6: cannot find symbol
symbol: constructor SwordItem(int,net.minecraft.src.EnumToolMaterial)
loaction: class net.minecraft.src.SwordItem
public static final Item ESword = new SwordItem(5803,EnumToolMaterial.EMERALD).setItemName("ESName");
Go there! http://www.minecraftforum.net/topic/734091-181-wip-sandstone-ore-mod/
Its because your using the custom file you made for the sword :/ Change SwordItem to ItemSword.