Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MinecraftRPGOverhaul.items;
- import java.awt.List;
- import java.util.ArrayList;
- import java.util.Arrays;
- import cpw.mods.fml.common.ObfuscationReflectionHelper;
- import net.minecraft.block.material.Material;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.PlayerCapabilities;
- import net.minecraft.init.Items;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemArmor;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.ItemArmor.ArmorMaterial;
- import net.minecraft.potion.Potion;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.world.World;
- public class ModArmor extends ItemArmor{
- //set the different weight classes
- private static final float HEAVYARMOR = 0.05f;
- private static final float MEDIUMARMOR = 0.025f;
- private static final float LIGHTARMOR = 0.01f;
- //weight for each armor piece
- private static float bootWeight = 0.0f;
- private static float chestplateWeight = 0.0f;
- private static float helmetWeight = 0.0f;
- private static float leggingWeight = 0.0f;
- //total armor weight
- private static float totalWeight = 0.0f;
- public static Item heavyBoots[] = new Item[] { ModItems.puriteBoots };
- public String textureName; //The texture name, the name is passed in via the 'ModArmor' method
- public ModArmor(String unlocalizedName, ArmorMaterial material, String textureName, int type){ //ModArmor method, passes in all pertinent information to create a piece of armor
- super(material, 0, type);
- this.textureName = textureName;
- this.setTextureName(unlocalizedName);
- }
- @Override
- 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
- return "rpgmod" + ":armor/" + this.textureName + "_" + (this.armorType == 2 ? "2" : "1") + ".png";
- }
- public static float armorCall(EntityPlayer player) {
- setCurrentArmorWeight(player);
- PlayerCapabilities cap = ObfuscationReflectionHelper.getPrivateValue(EntityPlayer.class, player, "capabilities", "field_71075_bZ");
- return ((1.0f - totalWeight)/10);
- }
- public static boolean wearingArmor (EntityPlayer player) {
- try {
- player.getCurrentArmor(0);
- System.out.println("Checked Armor!");
- return true;
- } catch(NullPointerException e) {
- System.out.println("Not wearing armour");
- return false;
- }
- }
- public static void setCurrentArmorWeight(EntityPlayer player) {
- if (wearingArmor(player)) {
- //TODO change to switch statements?
- if(player.getCurrentArmor(0).getItem().equals(ModItems.puriteBoots)){
- bootWeight = HEAVYARMOR;
- }
- if(player.getCurrentArmor(1).getItem().equals(ModItems.puriteLeggings)){
- leggingWeight = HEAVYARMOR;
- }
- if(player.getCurrentArmor(2).getItem().equals(ModItems.puriteChestplate)){
- chestplateWeight = HEAVYARMOR;
- }
- if(player.getCurrentArmor(3).getItem().equals(ModItems.puriteHelmet)) {
- helmetWeight = HEAVYARMOR;
- }
- totalWeight = bootWeight + helmetWeight + chestplateWeight + leggingWeight;
- } else {
- totalWeight = 0.0f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment