Hey guys, I've made this new armor type called DiamondEdged. I made a new Enum for the armor and stuff, there are no errors, I just can't wear the armor. I tried changing the armor material to DIAMOND and It worked. I'll post the mod, ItemArmor, and EnumArmorMaterial files I created. Any help is much appreciated! Thanks!
the mod
package net.minecraft.src;
import java.util.Random;
public class mod_everything extends BaseMod
{
public static Item PumpkinSpice;
public static final Item PumpkinCookie = (new ItemFood(999, 1, 1F, false)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PumpkinCookie.png")).setItemName("PumpkinCookie");
public static Item PurpleSword;
public static final Block CompressedObsidian;
public static final Block PureObsidian;
public static final Block DiamondEdgedObsidian;
public static Item DiamondEdgedIngot;
public static Item DiamondEdgedSword;
public static Item DiamondEdgedAxe;
public static Item DiamondEdgedShovel;
public static Item DiamondEdgedPick;
public static Item DiamondEdgedHoe;
static
{
PumpkinSpice = (new Item(1000)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PumpkinSpice.png")).setItemName("PumpkinSpice");
PurpleSword = (new ItemPurpleSword(8010, EnumToolMaterial.STONE)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PurpleSword.png")).setItemName("PurpleSword");
CompressedObsidian = (new BlockCompressedObsidian(200, ModLoader.addOverride("/terrain.png", "/mods/CompressedObsidian.png"))).setHardness(5F).setResistance(2000F).setStepSound(Block.soundStoneFootstep).setBlockName("CompressedObsidian");
PureObsidian = (new BlockPureObsidian(201, ModLoader.addOverride("/terrain.png", "/mods/PureObsidian.png"))).setHardness(5F).setResistance(2000F).setStepSound(Block.soundGlassFootstep).setBlockName("PureObsidian");
DiamondEdgedObsidian = (new BlockDiamondEdgedObsidian(202, ModLoader.addOverride("/terrain.png", "/mods/DiamondEdgedObsidian.png"))).setHardness(5F).setResistance(2000F).setStepSound(Block.soundGlassFootstep).setBlockName("DiamondEdgedObsidian");
DiamondEdgedIngot = (new Item(8004)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedIngot.png")).setItemName("DiamondEdgedIngot");
DiamondEdgedSword = (new ItemDiamondEdgedSword(8005, EnumDiamondEdgedToolMaterial.DIAMONDEDGED)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedSword.png")).setItemName("DiamondEdgedSword");
DiamondEdgedAxe = (new ItemDiamondEdgedAxe(8006, EnumDiamondEdgedToolMaterial.DIAMONDEDGED)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedAxe.png")).setItemName("DiamondEdgedAxe");
DiamondEdgedShovel = (new ItemDiamondEdgedShovel(8007, EnumDiamondEdgedToolMaterial.DIAMONDEDGED)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedShovel.png")).setItemName("DiamondEdgedShovel");
DiamondEdgedPick = (new ItemDiamondEdgedPick(8008, EnumDiamondEdgedToolMaterial.DIAMONDEDGED)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedPick.png")).setItemName("DiamondEdgedPick");
DiamondEdgedHoe = (new ItemDiamondEdgedHoe(8009, EnumDiamondEdgedToolMaterial.DIAMONDEDGED)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedHoe.png")).setItemName("DiamondEdgedHoe");
}
public void load()
{
//Pumpkin
ModLoader.addName(PumpkinSpice, "Pumpkin Spice");
ModLoader.addRecipe(new ItemStack(PumpkinSpice, 3), new Object[]{
"xxx", Character.valueOf('x'), Block.pumpkin
});
ModLoader.addName(PumpkinCookie, "Pumpkin Cookie");
ModLoader.addRecipe(new ItemStack(PumpkinCookie, 8), new Object[]{
"wsw", Character.valueOf('s'), PumpkinSpice, Character.valueOf('w'), Item.wheat
});
//CoLoRs!
ModLoader.addName(PurpleSword, "Purple Sword");
ModLoader.addRecipe(new ItemStack(PurpleSword, 1), new Object[]{
" p ", " p ", " s ", Character.valueOf('p'), Block.cloth, Character.valueOf('s'), Item.stick
});
//Diamond Edged Obsidian
ModLoader.registerBlock(CompressedObsidian);
ModLoader.addName(CompressedObsidian, "Compressed Obsidian");
ModLoader.addRecipe(new ItemStack(CompressedObsidian, 1), new Object[]{
"ooo", "ooo", "ooo", Character.valueOf('o'), Block.obsidian
});
ModLoader.registerBlock(PureObsidian);
ModLoader.addName(PureObsidian, "Pure Obsidian");
ModLoader.addSmelting(CompressedObsidian.blockID, new ItemStack(PureObsidian, 1));
ModLoader.registerBlock(DiamondEdgedObsidian);
ModLoader.addName(DiamondEdgedObsidian, "Diamond Edged Obsidian");
ModLoader.addRecipe(new ItemStack(DiamondEdgedObsidian, 1), new Object[]{
"od", Character.valueOf('o'), PureObsidian, Character.valueOf('d'), Item.diamond
});
ModLoader.addName(DiamondEdgedIngot, "Diamond Edged Ingot");
ModLoader.addSmelting(DiamondEdgedObsidian.blockID, new ItemStack(DiamondEdgedIngot));
ModLoader.addName(DiamondEdgedSword, "Diamond Edged Sword");
ModLoader.addRecipe(new ItemStack(DiamondEdgedSword, 1), new Object []{
" d ", " d ", " s ", Character.valueOf('d'), DiamondEdgedIngot, Character.valueOf('s'), Item.stick
});
ModLoader.addName(DiamondEdgedAxe, "Diamond Edged Axe");
ModLoader.addRecipe(new ItemStack(DiamondEdgedAxe, 1), new Object []{
"dd ", "ds ", " s ", Character.valueOf('d'), DiamondEdgedIngot, Character.valueOf('s'), Item.stick
});
ModLoader.addName(DiamondEdgedShovel, "Diamond Edged Shovel");
ModLoader.addRecipe(new ItemStack(DiamondEdgedShovel, 1), new Object []{
" d ", " s ", " s ", Character.valueOf('d'), DiamondEdgedIngot, Character.valueOf('s'), Item.stick
});
ModLoader.addName(DiamondEdgedPick, "Diamond Edged Pickaxe");
ModLoader.addRecipe(new ItemStack(DiamondEdgedPick, 1), new Object []{
"ddd", " s ", " s ", Character.valueOf('d'), DiamondEdgedIngot, Character.valueOf('s'), Item.stick
});
ModLoader.addName(DiamondEdgedHoe, "Diamond Edged Hoe");
ModLoader.addRecipe(new ItemStack(DiamondEdgedHoe, 1), new Object []{
"dd ", " s ", " s ", Character.valueOf('d'), DiamondEdgedIngot, Character.valueOf('s'), Item.stick
});
}
public static Item PumpkinHelmet;
public static Item PumpkinChest;
public static Item PumpkinLegs;
public static Item PumpkinBoots;
public static Item DiamondEdgedHelmet;
public static Item DiamondEdgedChest;
public static Item DiamondEdgedLegs;
public static Item DiamondEdgedBoots;
public mod_everything()
{
ModLoader.registerBlock(CompressedObsidian);
ModLoader.registerBlock(PureObsidian);
ModLoader.registerBlock(DiamondEdgedObsidian);
}
static
{
PumpkinHelmet = (new ItemArmor(8000, EnumArmorMaterial.CLOTH, 5, 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PumpkinHelmet.png")).setItemName("PumpkinHelmet");
PumpkinChest = (new ItemArmor(8001, EnumArmorMaterial.CLOTH, 5, 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PumpkinChest.png")).setItemName("PumpkinChest");
PumpkinLegs = (new ItemArmor(8002, EnumArmorMaterial.CLOTH, 5, 2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PumpkinLegs.png")).setItemName("PumpkinLegs");
PumpkinBoots = (new ItemArmor(8003, EnumArmorMaterial.CLOTH, 5, 3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/PumpkinBoots.png")).setItemName("PumpkinBoots");
ModLoader.addName(PumpkinHelmet, "Pumpkin Helmet");
ModLoader.addName(PumpkinChest, "Pumpkin Chestplate");
ModLoader.addName(PumpkinLegs, "Pumpkin Leggings");
ModLoader.addName(PumpkinBoots, "Pumpkin Boots");
ModLoader.addArmor("pumpkin");
ModLoader.addRecipe(new ItemStack(PumpkinHelmet, 1), new Object[]{
"ppp", "p p", Character.valueOf('p'), Block.pumpkin
});
ModLoader.addRecipe(new ItemStack(PumpkinChest, 1), new Object[]{
"p p", "ppp", "ppp", Character.valueOf('p'), Block.pumpkin
});
ModLoader.addRecipe(new ItemStack(PumpkinLegs, 1), new Object[]{
"ppp", "p p", "p p", Character.valueOf('p'), Block.pumpkin
});
ModLoader.addRecipe(new ItemStack(PumpkinBoots, 1), new Object[]{
"p p", "p p", Character.valueOf('p'), Block.pumpkin
});
DiamondEdgedHelmet = (new ItemDiamondEdgedArmor(8011, EnumDiamondEdgedArmorMaterial.DIAMONDEDGED, 6, 0)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedHelmet.png")).setItemName("DiamondEdgedHelmet");
DiamondEdgedChest = (new ItemDiamondEdgedArmor(8012, EnumDiamondEdgedArmorMaterial.DIAMONDEDGED, 6, 1)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedChest.png")).setItemName("DiamondEdgedChest");
DiamondEdgedLegs = (new ItemDiamondEdgedArmor(8013, EnumDiamondEdgedArmorMaterial.DIAMONDEDGED, 6, 2)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedLegs.png")).setItemName("DiamondEdgedLegs");
DiamondEdgedBoots = (new ItemDiamondEdgedArmor(8014, EnumDiamondEdgedArmorMaterial.DIAMONDEDGED, 6, 3)).setIconIndex(ModLoader.addOverride("/gui/items.png", "/mods/DiamondEdgedBoots.png")).setItemName("DiamondEdgedBoots");
ModLoader.addName(DiamondEdgedHelmet, "Diamond Edged Helmet");
ModLoader.addName(DiamondEdgedChest, "Diamond Edged Chestplate");
ModLoader.addName(DiamondEdgedLegs, "Diamond Edged Leggings");
ModLoader.addName(DiamondEdgedBoots, "Diamond Edged Boots");
ModLoader.addArmor("DiamondEdged");
ModLoader.addRecipe(new ItemStack(DiamondEdgedHelmet, 1), new Object[]{
"ppp", "p p", Character.valueOf('p'), Block.dirt
});
ModLoader.addRecipe(new ItemStack(DiamondEdgedChest, 1), new Object[]{
"p p", "ppp", "ppp", Character.valueOf('p'), Block.dirt
});
ModLoader.addRecipe(new ItemStack(DiamondEdgedLegs, 1), new Object[]{
"ppp", "p p", "p p", Character.valueOf('p'), Block.dirt
});
ModLoader.addRecipe(new ItemStack(DiamondEdgedBoots, 1), new Object[]{
"p p", "p p", Character.valueOf('p'), Block.dirt
});
}
@Override
public String getVersion() {
// TODO Auto-generated method stub
return null;
}
}
ItemDiamondEdgedArmor
package net.minecraft.src;
public class ItemDiamondEdgedArmor extends Item
{
private static final int maxDamageArray[] =
{
11, 16, 15, 13
};
/**
* Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots
*/
public final int armorType;
/** Holds the amount of damage that the armor reduces at full durability. */
public final int damageReduceAmount;
/**
* Used on RenderPlayer to select the correspondent armor to be rendered on the player: 0 is cloth, 1 is chain, 2 is
* iron, 3 is diamond and 4 is gold.
*/
public final int renderIndex;
/** The EnumArmorMaterial used for this ItemArmor */
private final EnumDiamondEdgedArmorMaterial material;
public ItemDiamondEdgedArmor(int par1, EnumDiamondEdgedArmorMaterial par2EnumArmorMaterial, int par3, int par4)
{
super(par1);
material = par2EnumArmorMaterial;
armorType = par4;
renderIndex = par3;
damageReduceAmount = par2EnumArmorMaterial.getDamageReductionAmount(par4);
setMaxDamage(par2EnumArmorMaterial.getDurability(par4));
maxStackSize = 1;
}
/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return material.getEnchantability();
}
/**
* Returns the 'max damage' factor array for the armor, each piece of armor have a durability factor (that gets
* multiplied by armor material factor)
*/
static int[] getMaxDamageArray()
{
return maxDamageArray;
}
}
and the new EnumArmorMaterial
package net.minecraft.src;
public enum EnumDiamondEdgedArmorMaterial
{
DIAMONDEDGED(40, new int[] {
3, 10, 8, 3
}, 0);
/**
* Holds the maximum damage factor (each piece multiply this by it's own value) of the material, this is the item
* damage (how much can absorb before breaks)
*/
private int maxDamageFactor;
private int damageReductionAmountArray[];
/** Return the enchantability factor of the material */
private int enchantability;
private EnumDiamondEdgedArmorMaterial(int par3, int par4ArrayOfInteger[], int par5)
{
maxDamageFactor = par3;
damageReductionAmountArray = par4ArrayOfInteger;
enchantability = par5;
}
/**
* Returns the durability for a armor slot of for this type.
*/
public int getDurability(int par1)
{
return ItemArmor.getMaxDamageArray()[par1] * maxDamageFactor;
}
/**
* Return the damage reduction (each 1 point is a half a shield on gui) of the piece index passed (0 = helmet, 1 =
* plate, 2 = legs and 3 = boots)
*/
public int getDamageReductionAmount(int par1)
{
return damageReductionAmountArray[par1];
}
/**
* Return the enchantability factor of the material.
*/
public int getEnchantability()
{
return enchantability;
}
}
Can you just add a new material to the EnumArmorMaterial file? I heard that would just set off a nasty chain of errors...
Yes, you can add a new material. Just copy one of them and determine what the ints mean. Make sure you end lines correctly, either with a comma or a semicolon.
Yes, you can add a new material. Just copy one of them and determine what the ints mean. Make sure you end lines correctly, either with a comma or a semicolon.
You can also use refection (or just use forge) to add Materials.
Yes, you can add a new material. Just copy one of them and determine what the ints mean. Make sure you end lines correctly, either with a comma or a semicolon.
so you're telling me, just add my own using the same... format... as say "EMERALD" and add it right below gold. so long as I add the correct values and format as the others, it should work?\
and I've got no idea how to use reflection. that was suggested to me before, and i'm kinda new at java still, i've just been following tuts. this whole armor thing was my first attempt at my own thing. and it looked like it should have worked the way I set it up. It works with tools just fine >.> except wit tools, I have to make all the tool classes individually. Armor doesn't have an individual helmet.class like the tools do.
so you're telling me, just add my own using the same... format... as say "EMERALD" and add it right below gold. so long as I add the correct values and format as the others, it should work?\
and I've got no idea how to use reflection. that was suggested to me before, and i'm kinda new at java still, i've just been following tuts. this whole armor thing was my first attempt at my own thing. and it looked like it should have worked the way I set it up. It works with tools just fine >.> except wit tools, I have to make all the tool classes individually. Armor doesn't have an individual helmet.class like the tools do.
If you want your mod to be compatible with other mods you will need to use Minecraft forge (you should be able to just use the EnumHelper class from it and last I checked it would be OK to just include that with your mod as long as you make it clear you are doing so) otherwise just edit the base class.
the mod
ItemDiamondEdgedArmor
and the new EnumArmorMaterial
and there's a way to do this without messing with the Armor enum.. but I can't seem to remember how atm..
of course
everything works except the items won;t go into the armor slots in the game
oh i thought you meant you couldnt see the armor
but if there were another way without edditing the armor file that would be way better.
Can you just add a new material to the EnumArmorMaterial file? I heard that would just set off a nasty chain of errors...
Yes, you can add a new material. Just copy one of them and determine what the ints mean. Make sure you end lines correctly, either with a comma or a semicolon.
You can also use refection (or just use forge) to add Materials.
so you're telling me, just add my own using the same... format... as say "EMERALD" and add it right below gold. so long as I add the correct values and format as the others, it should work?\
and I've got no idea how to use reflection. that was suggested to me before, and i'm kinda new at java still, i've just been following tuts. this whole armor thing was my first attempt at my own thing. and it looked like it should have worked the way I set it up. It works with tools just fine >.> except wit tools, I have to make all the tool classes individually. Armor doesn't have an individual helmet.class like the tools do.
If you want your mod to be compatible with other mods you will need to use Minecraft forge (you should be able to just use the EnumHelper class from it and last I checked it would be OK to just include that with your mod as long as you make it clear you are doing so) otherwise just edit the base class.