drackiseries

Custom Armor Material

Jun 24th, 2012
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.95 KB | None | 0 0
  1. MOD_FILE STATEMENTS:
  2.  
  3. public static final Item RHelmet = (new ItemArmorRedstone(1012,EnumArmorMaterialMod.REDSTONE, ModLoader.addArmor("redstone"), 0).setItemName("RHelmet"));
  4.     public static final Item RChestplate = (new ItemArmorRedstone(1013,EnumArmorMaterialMod.REDSTONE, ModLoader.addArmor("redstone"), 1).setItemName("RChestplate"));
  5.     public static final Item RLeggings = (new ItemArmorRedstone(1014,EnumArmorMaterialMod.REDSTONE, ModLoader.addArmor("redstone"), 2).setItemName("RLeggings"));
  6.     public static final Item RBoots = (new ItemArmorRedstone(1015,EnumArmorMaterialMod.REDSTONE, ModLoader.addArmor("redstone"), 3).setItemName("RBoots"));
  7.  
  8. ITEMARMORREDSTONE FILE CONTENTS:
  9.  
  10.  
  11. package net.minecraft.src;
  12.  
  13. public class ItemArmorRedstone extends Item
  14. {
  15.     private static final int maxDamageArray[] =
  16.     {
  17.         11, 16, 15, 13
  18.     };
  19.  
  20.     /**
  21.      * Stores the armor type: 0 is helmet, 1 is plate, 2 is legs and 3 is boots
  22.      */
  23.     public final int armorType;
  24.  
  25.     /** Holds the amount of damage that the armor reduces at full durability. */
  26.     public final int damageReduceAmount;
  27.  
  28.     /**
  29.      * Used on RenderPlayer to select the correspondent armor to be rendered on the player: 0 is cloth, 1 is chain, 2 is
  30.      * iron, 3 is diamond and 4 is gold.
  31.      */
  32.     public final int renderIndex;
  33.  
  34.     /** The EnumArmorMaterial used for this ItemArmor */
  35.     private final EnumArmorMaterialMod material;
  36.  
  37.     public ItemArmorRedstone(int par1, EnumArmorMaterialMod par2EnumArmorMaterialMod, int par3, int par4)
  38.     {
  39.         super(par1);
  40.         material = par2EnumArmorMaterialMod;
  41.         armorType = par4;
  42.         renderIndex = par3;
  43.         damageReduceAmount = par2EnumArmorMaterialMod.getDamageReductionAmount(par4);
  44.         setMaxDamage(par2EnumArmorMaterialMod.getDurability(par4));
  45.         maxStackSize = 1;
  46.     }
  47.  
  48.     /**
  49.      * Return the enchantability factor of the item, most of the time is based on material.
  50.      */
  51.     public int getItemEnchantability()
  52.     {
  53.         return material.getEnchantability();
  54.     }
  55.  
  56.     /**
  57.      * Returns the 'max damage' factor array for the armor, each piece of armor have a durability factor (that gets
  58.      * multiplied by armor material factor)
  59.      */
  60.     static int[] getMaxDamageArray()
  61.     {
  62.         return maxDamageArray;
  63.     }
  64. }
  65.  
  66.  
  67. ENUM ARMOR MATERIAL MOD FILE CONTENTS:
  68.  
  69.  
  70. package net.minecraft.src;
  71.  
  72. public enum EnumArmorMaterialMod
  73. {
  74.     REDSTONE(27, new int[] {
  75.         2, 7, 5, 2
  76.     }, 10);
  77.     /**CHAIN(15, new int[] {
  78.         2, 5, 4, 1
  79.     }, 12),
  80.     IRON(15, new int[] {
  81.         2, 6, 5, 2
  82.     }, 9),
  83.     GOLD(7, new int[] {
  84.         2, 5, 3, 1
  85.     }, 25),
  86.     DIAMOND(33, new int[] {
  87.         3, 8, 6, 3
  88.     }, 10); **/
  89.  
  90.     /**
  91.      * Holds the maximum damage factor (each piece multiply this by it's own value) of the material, this is the item
  92.      * damage (how much can absorb before breaks)
  93.      */
  94.     private int maxDamageFactor;
  95.     private int damageReductionAmountArray[];
  96.  
  97.     /** Return the enchantability factor of the material */
  98.     private int enchantability;
  99.  
  100.     private EnumArmorMaterialMod(int par3, int par4ArrayOfInteger[], int par5)
  101.     {
  102.         maxDamageFactor = par3;
  103.         damageReductionAmountArray = par4ArrayOfInteger;
  104.         enchantability = par5;
  105.     }
  106.  
  107.     /**
  108.      * Returns the durability for a armor slot of for this type.
  109.      */
  110.     public int getDurability(int par1)
  111.     {
  112.         return ItemArmor.getMaxDamageArray()[par1] * maxDamageFactor;
  113.     }
  114.  
  115.     /**
  116.      * Return the damage reduction (each 1 point is a half a shield on gui) of the piece index passed (0 = helmet, 1 =
  117.      * plate, 2 = legs and 3 = boots)
  118.      */
  119.     public int getDamageReductionAmount(int par1)
  120.     {
  121.         return damageReductionAmountArray[par1];
  122.     }
  123.  
  124.     /**
  125.      * Return the enchantability factor of the material.
  126.      */
  127.     public int getEnchantability()
  128.     {
  129.         return enchantability;
  130.     }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment