Guest User

Untitled

a guest
Mar 9th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. package MinecraftRPGOverhaul.items;
  2.  
  3. import java.awt.List;
  4. import java.util.ArrayList;
  5. import java.util.Arrays;
  6.  
  7. import cpw.mods.fml.common.ObfuscationReflectionHelper;
  8. import net.minecraft.block.material.Material;
  9. import net.minecraft.entity.Entity;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.entity.player.PlayerCapabilities;
  12. import net.minecraft.init.Items;
  13. import net.minecraft.item.Item;
  14. import net.minecraft.item.ItemArmor;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.item.ItemArmor.ArmorMaterial;
  17. import net.minecraft.potion.Potion;
  18. import net.minecraft.potion.PotionEffect;
  19. import net.minecraft.world.World;
  20.  
  21. public class ModArmor extends ItemArmor{
  22.  
  23. //set the different weight classes
  24. private static final float HEAVYARMOR = 0.05f;
  25. private static final float MEDIUMARMOR = 0.025f;
  26. private static final float LIGHTARMOR = 0.01f;
  27.  
  28. //weight for each armor piece
  29. private static float bootWeight = 0.0f;
  30. private static float chestplateWeight = 0.0f;
  31. private static float helmetWeight = 0.0f;
  32. private static float leggingWeight = 0.0f;
  33.  
  34. //total armor weight
  35. private static float totalWeight = 0.0f;
  36.  
  37. public static Item heavyBoots[] = new Item[] { ModItems.puriteBoots };
  38.  
  39. public String textureName; //The texture name, the name is passed in via the 'ModArmor' method
  40.  
  41. public ModArmor(String unlocalizedName, ArmorMaterial material, String textureName, int type){ //ModArmor method, passes in all pertinent information to create a piece of armor
  42.  
  43. super(material, 0, type);
  44. this.textureName = textureName;
  45. this.setTextureName(unlocalizedName);
  46. }
  47.  
  48. @Override
  49. public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ //getArmorTexture method, uses previous information passed in to assure you have the right texture
  50. return "rpgmod" + ":armor/" + this.textureName + "_" + (this.armorType == 2 ? "2" : "1") + ".png";
  51. }
  52.  
  53. public static float armorCall(EntityPlayer player) {
  54. setCurrentArmorWeight(player);
  55.  
  56. PlayerCapabilities cap = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class, player, "capabilities", "field_71075_bZ");
  57. return ((1.0f - totalWeight)/10);
  58.  
  59.  
  60. }
  61.  
  62. public static boolean wearingArmor (EntityPlayer player) {
  63.  
  64. try {
  65. player.getCurrentArmor(0);
  66. System.out.println("Checked Armor!");
  67. return true;
  68.  
  69.  
  70. } catch(NullPointerException e) {
  71. System.out.println("Not wearing armour");
  72. return false;
  73. }
  74. }
  75.  
  76. public static void setCurrentArmorWeight(EntityPlayer player) {
  77. if (wearingArmor(player)) {
  78. //TODO change to switch statements?
  79. if(player.getCurrentArmor(0).getItem().equals(ModItems.puriteBoots)){
  80. bootWeight = HEAVYARMOR;
  81. }
  82. if(player.getCurrentArmor(1).getItem().equals(ModItems.puriteLeggings)){
  83. leggingWeight = HEAVYARMOR;
  84. }
  85. if(player.getCurrentArmor(2).getItem().equals(ModItems.puriteChestplate)){
  86. chestplateWeight = HEAVYARMOR;
  87. }
  88. if(player.getCurrentArmor(3).getItem().equals(ModItems.puriteHelmet)) {
  89. helmetWeight = HEAVYARMOR;
  90. }
  91.  
  92. totalWeight = bootWeight + helmetWeight + chestplateWeight + leggingWeight;
  93.  
  94. } else {
  95. totalWeight = 0.0f;
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment